Your IP : 216.73.216.196


Current Path : /opt/alt/python27/lib/python2.7/site-packages/betamax/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pyc

�
@u`Wc@spddlmZmZddlmZddlmZddlmZddl	m
Z
defd��YZdS(	i(tmatcherstserializers(tBetamaxAdapter(tCassette(t
Configuration(tOptionstBetamaxcBs�eZdZdid�Zd�Zd�Zed��Ze	d��Z
ed��Zed��Zd�Z
d	�Zd
�ZRS(sThis object contains the main API of the request-vcr library.

    This object is entirely a context manager so all you have to do is:

    .. code::

        s = requests.Session()
        with Betamax(s) as vcr:
            vcr.use_cassette('example')
            r = s.get('https://httpbin.org/get')

    Or more concisely, you can do:

    .. code::

        s = requests.Session()
        with Betamax(s).use_cassette('example') as vcr:
            r = s.get('https://httpbin.org/get')

    This object allows for the user to specify the cassette library directory
    and default cassette options.

    .. code::

        s = requests.Session()
        with Betamax(s, cassette_library_dir='tests/cassettes') as vcr:
            vcr.use_cassette('example')
            r = s.get('https://httpbin.org/get')

        with Betamax(s, default_cassette_options={
                're_record_interval': 1000
                }) as vcr:
            vcr.use_cassette('example')
            r = s.get('https://httpbin.org/get')

    cCsn||_|jj�|_td|j�|_t�|_|jjj	|pQi�|rj||j_
ndS(Ntold_adapters(tsessiontadapterstcopyt
http_adaptersRtbetamax_adapterRtconfigtdefault_cassette_optionstupdatetcassette_library_dir(tselfRRR((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pyt__init__0s	
cCs|j�|S(N(tstart(R((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pyt	__enter__Cs
cGs|j�t|�rtSdS(N(tstoptanytFalse(Rtex_args((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pyt__exit__Gs
cCst�S(sAHelp to configure the library as a whole.

        .. code::

            with Betamax.configure() as config:
                config.cassette_library_dir = 'tests/cassettes/'
                config.default_cassette_options['match_options'] = [
                    'method', 'uri', 'headers'
                    ]
        (R(((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pyt	configurePscCs
|jjS(swReturn the cassette that is currently in use.

        :returns: :class:`Cassette <betamax.cassette.Cassette>`
        (Rtcassette(R((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pytcurrent_cassette^scCs|�tj|j<dS(s�Register a new request matcher.

        :param matcher_class: (required), this must sub-class
            :class:`BaseMatcher <betamax.matchers.BaseMatcher>`
        N(Rtmatcher_registrytname(t
matcher_class((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pytregister_request_matcherfscCs|j}|�tj|<dS(s�Register a new serializer.

        :param matcher_class: (required), this must sub-class
            :class:`BaseSerializer <betamax.serializers.BaseSerializer>`
        N(RRtserializer_registry(tserializer_classR((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pytregister_serializeros	cCs.x'|jD]}|jj||j�q
WdS(s*Start recording or replaying interactions.N(RRtmountR(Rtk((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pyRzscCsQ|jj�|jj�x0|jj�D]\}}|jj||�q*WdS(s)Stop recording or replaying interactions.N(Rteject_cassettetcloseRtitemsRR$(RR%tv((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pyR�s

cKs�t|�}|dp|d}|jj|d<tj|jj|||d�}|rq|jj|||�ntd��|S(s�Tell Betamax which cassette you wish to use for the context.

        :param str cassette_name: relative name, without the serialization
            format, of the cassette you wish Betamax would use
        :param str serialize_with: the format you want Betamax to serialize
            the cassette with
        :param str serialize: DEPRECATED the format you want Betamax to
            serialize the request and response data to and from
        t	serializetserialize_withRtrecords4Cassette must have a valid name and may not be None.(RR
RRt
can_be_loadedRt
load_cassettet
ValueError(Rt
cassette_nametkwargsR*tcan_load((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pytuse_cassette�s
	

N(t__name__t
__module__t__doc__tNoneRRRtstaticmethodRtpropertyRR R#RRR3(((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pyR	s%						
N(
tRRtadapterRRRRRtoptionsRtobjectR(((sA/opt/alt/python27/lib/python2.7/site-packages/betamax/recorder.pyt<module>s