Your IP : 216.73.216.61
B
xG�ZA � @ s d Z G dd� de�ZdS )zJThis method must be implemented by classes inheriting from BaseSerializer.c @ s@ e Zd ZdZdZedd� �Zdd� Zdd� Zd d
� Z dd� Z
dS )
�BaseSerializera2
Base Serializer class that provides an interface for other serializers.
Usage:
.. code-block:: python
from betamax import Betamax, BaseSerializer
class MySerializer(BaseSerializer):
name = 'my'
@staticmethod
def generate_cassette_name(cassette_library_dir, cassette_name):
# Generate a string that will give the relative path of a
# cassette
def serialize(self, cassette_data):
# Take a dictionary and convert it to whatever
def deserialize(self, cassette_data):
# Uses a cassette file to return a dictionary with the
# cassette information
Betamax.register_serializer(MySerializer)
The last line is absolutely necessary.
Nc C s t t��d S )N)�NotImplementedError�NOT_IMPLEMENTED_ERROR_MSG)Zcassette_library_dirZ
cassette_name� r �I/opt/alt/python37/lib/python3.7/site-packages/betamax/serializers/base.py�generate_cassette_name) s z%BaseSerializer.generate_cassette_namec C s | j std��| �� d S )Nz=Serializer's name attribute must be a string value, not None.)�name�
ValueError�on_init)�selfr r r �__init__- s zBaseSerializer.__init__c C s dS )ap Method to implement if you wish something to happen in ``__init__``.
The return value is not checked and this is called at the end of
``__init__``. It is meant to provide the matcher author a way to
perform things during initialization of the instance that would
otherwise require them to override ``BaseSerializer.__init__``.
Nr )r
r r r r 4 s zBaseSerializer.on_initc C s t t��dS )z�A method that must be implemented by the Serializer author.
:param dict cassette_data: A dictionary with two keys:
``http_interactions``, ``recorded_with``.
:returns: Serialized data as a string.
N)r r )r
�
cassette_datar r r � serialize>