Your IP : 216.73.216.61


Current Path : /opt/alt/python37/lib/python3.7/site-packages/betamax/serializers/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/betamax/serializers/__pycache__/base.cpython-37.pyc

B

xG�ZA�@sdZGdd�de�ZdS)zJThis method must be implemented by classes inheriting from BaseSerializer.c@s@eZdZdZdZedd��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.

    NcCstt��dS)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)sz%BaseSerializer.generate_cassette_namecCs|jstd��|��dS)Nz=Serializer's name attribute must be a string value, not None.)�name�
ValueError�on_init)�selfrrr�__init__-szBaseSerializer.__init__cCsdS)apMethod 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
rrrr	4szBaseSerializer.on_initcCstt��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)rr)r
�
cassette_datarrr�	serialize>szBaseSerializer.serializecCstt��dS)aQA method that must be implemented by the Serializer author.

        The return value is extremely important. If it is not empty, the
        dictionary returned must have the following structure::

            {
                'http_interactions': [{
                    # Interaction
                },
                {
                    # Interaction
                }],
                'recorded_with': 'name of recorder'
            }

        :params str cassette_data: The data serialized as a string which needs
            to be deserialized.
        :returns: dictionary
        N)rr)r
rrrr�deserializeGszBaseSerializer.deserialize)�__name__�
__module__�__qualname__�__doc__r�staticmethodrrr	r
rrrrrrs
	rN)r�objectrrrrr�<module>s