Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / kombu / serialization.pyc
Size: Mime:
ó
öEYc@@s@dZddlmZmZddlZddlZddlZddlZyddl	Z
Wnek
rudZ
nXddl
mZddlmZddlmZddlmZmZmZmZdd	lmZmZdd
lmZddlmZmZm Z dd
dddgZ!e"ddgƒZ#e"ddgƒZ$ej%j&dƒrad„Z'n	ej(Z'e
pseZej)Z*e+ej,j-ddƒƒZ.edd4ƒZ/ee0fefd„ƒZ1e*d„Z2d„Z3d e4fd!„ƒYZ5e5ƒZ6e6j7Z7e6j8Z8e6j9Z9e6j:Z:d"„Z;d#„Z<d$„Z=ej>dd%krVd&„Z?ne2Z?d'„Z@d(„ZAe<ƒe@ƒe=ƒeAƒe6jBd)ƒie<d)6e@d6e=d*6eAd+6e<d,6e=d-6e@d.6eAd/6ZCdd*d+gd0„ZDd)gd1„ZEeEƒx*ed2ƒD]\ZFZGe9eFjHeGŒq
We6jId3„ZJdS(5uSerialization utilities.i(tabsolute_importtunicode_literalsN(t
namedtuple(tcontextmanager(tBytesIOi(tContentDisallowedtDecodeErrortEncodeErrortSerializerNotInstalled(treraisettext_t(tentrypoints(tbytes_to_strtstr_to_bytestbytes_tupickleuloadsudumpsuregisteru
unregisterubinaryu
ascii-8bituapplication/datauapplication/textujavacC@stj|ƒ|ƒdS(Ni(tcodecst
getdecoder(tttcoding((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyt_decodesuPICKLE_PROTOCOLiucodecucontent_typeucontent_encodinguencodercc@sVy	dVWnF|k
r‚n3|k
rQ}t|||ƒtjƒdƒnXdS(Ni(R	tsystexc_info(twrappertincludetexcludetexc((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyt_reraise_errors.s	
cC@s|t|ƒƒS(N(R(tstload((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytpickle_loads9scC@s|rd||fS|S(Nu%s (%s)((tfirsttsecond((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytparenthesize_alias>stSerializerRegistrycB@sneZdZd„Zdd„Zd„Zd„Zd„Zd„Zdd„Z
deed	„Z
d
„ZRS(u2The registry keeps track of serialization methods.cC@sOi|_i|_d|_d|_d|_tƒ|_i|_i|_	dS(N(
t	_encoderst	_decoderstNonet_default_encodet_default_content_typet_default_content_encodingtsett_disabled_content_typesttype_to_nametname_to_type(tself((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyt__init__Es						uutf-8cC@sV|r"t|||ƒ|j|<n|r8||j|<n||j|<||j|<dS(uêRegister a new encoder/decoder.

        Arguments:
            name (str): A convenience name for the serialization method.

            encoder (callable): A method that will be passed a python data
                structure and should return a string representing the
                serialized data.  If :const:`None`, then only a decoder
                will be registered. Encoding will not be possible.

            decoder (Callable): A method that will be passed a string
                representing serialized data and should return a python
                data structure.  If :const:`None`, then only an encoder
                will be registered.  Decoding will not be possible.

            content_type (str): The mime-type describing the serialized
                structure.

            content_encoding (str): The content encoding (character set) that
                the `decoder` method will be returning. Will usually be
                `utf-8`, `us-ascii`, or `binary`.
        N(tcodecR"R#R*R+(R,tnametencodertdecodertcontent_typetcontent_encoding((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytregisterOs
cC@s0d|kr|j|}n|jj|ƒdS(Nu/(R+R)tdiscard(R,R/((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytenablepscC@s0d|kr|j|}n|jj|ƒdS(Nu/(R+R)tadd(R,R/((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytdisableuscC@sŠy]|j|}|jj|dƒ|jj|dƒ|jj|dƒ|jj|dƒWn&tk
r…tdj|ƒƒ‚nXdS(uôUnregister registered encoder/decoder.

        Arguments:
            name (str): Registered serialization method name.

        Raises:
            SerializerNotInstalled: If a serializer by that name
                cannot be found.
        u$No encoder/decoder installed for {0}N(	R+R#tpopR$R"R*tKeyErrorRtformat(R,R/R2((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyt
unregisterzs


cC@sPy#|j|\|_|_|_Wn&tk
rKtdj|ƒƒ‚nXdS(u²Set the default serialization method used by this library.

        Arguments:
            name (str): The name of the registered serialization method.
                For example, `json` (default), `pickle`, `yaml`, `msgpack`,
                or any custom methods registered using :meth:`register`.

        Raises:
            SerializerNotInstalled: If the serialization method
                requested is not available.
        uNo encoder installed for {0}N(R"R&R'R%R:RR;(R,R/((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyt_set_default_serializerŽs
#
c
C@s|dkrt|ƒS|rG|jj|ƒrGtdj|ƒƒ‚n|rjt|tƒrjdd|fS|rµt|tƒrµtt	dd	ƒ|j
dƒ}WdQXdd|fS|rÔ|j|\}}}n|j}|j}|j
}tt	ƒ||ƒ}WdQX|||fS(
u·Encode data.

        Serialize a data structure into a string suitable for sending
        as an AMQP message body.

        Arguments:
            data (List, Dict, str): The message data to send.

            serializer (str): An optional string representing
                the serialization method you want the data marshalled
                into. (For example, `json`, `raw`, or `pickle`).

                If :const:`None` (default), then json will be used, unless
                `data` is a :class:`str` or :class:`unicode` object. In this
                latter case, no serialization occurs as it would be
                unnecessary.

                Note that if `serializer` is specified, then that
                serialization method will be used even if a :class:`str`
                or :class:`unicode` object is passed in.

        Returns:
            Tuple[str, str, str]: A three-item tuple containing the
            content type (e.g., `application/json`), content encoding, (e.g.,
            `utf-8`) and a string containing the serialized data.

        Raises:
            SerializerNotInstalled: If the serialization method
                requested is not available.
        urawuNo encoder installed for {0}uapplication/dataubinaryRuutf-8Nu
text/plain((t
raw_encodeR"tgetRR;t
isinstanceRR
RRtencodeR%R&R'(R,tdatat
serializertpayloadR2R3R0((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytdumps¡s&


			
cC@s|rt|ƒnd}|dk	rT||kr||kr|j|dƒ‚qn+||jkr|r|j|dƒ‚n|pˆdjƒ}|r|jj|ƒ}|rÏttƒ||ƒSWdQXn|t	krt
|tƒrttƒt||ƒSWdQXqn|S(u“Decode serialized data.

        Deserialize a data stream as serialized using `dumps`
        based on `content_type`.

        Arguments:
            data (bytes, buffer, str): The message data to deserialize.

            content_type (str): The content-type of the data.
                (e.g., `application/json`).

            content_encoding (str): The content-encoding of the data.
                (e.g., `utf-8`, `binary`, or `us-ascii`).

            accept (Set): List of content-types to accept.

        Raises:
            ContentDisallowed: If the content-type is not accepted.

        Returns:
            Any: The unserialized data.
        uapplication/datau	untrustedudisableduutf-8N(
RR$t_for_untrusted_contentR)tlowerR#R?RRtSKIP_DECODER@R
R(R,RBR2R3taccepttforcet_trusted_contenttdecode((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytloadsàs&

cC@s.tdj|t|jj||ƒ|ƒƒƒS(Nu/Refusing to deserialize {0} content of type {1}(RR;R R*R?(R,tctypetwhy((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyRFsN(t__name__t
__module__t__doc__R-R4R6R8R<R=R$REtFalsetTRUSTED_CONTENTRMRF(((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyR!Bs	 				@-cC@s_d}|}t|tƒrLd}ttddƒ|j|ƒ}WdQXnd}|||fS(uSpecial case serializer.uapplication/datauutf-8RNubinary((R@R
RRRA(RBR2RDR3((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyR>scC@s9ddlm}tjd|j|jddddƒdS(	u2Register a encoder/decoder for JSON serialization.i(tjsonujsonR2uapplication/jsonR3uutf-8N(tkombu.utilsRUtregistryR4RERM(t_json((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyt
register_json,scC@sly5ddl}tjd|j|jddddƒWn0tk
rgd„}tjdd|dƒnXdS(	u¸Register a encoder/decoder for YAML serialization.

    It is slower than JSON, but allows for more data types
    to be serialized. Useful if you need to send data such as dates

    iNuyamlR2uapplication/x-yamlR3uutf-8c_@stdƒ‚dS(uŒRaise SerializerNotInstalled.

            Used in case a client receives a yaml message, but yaml
            isn't installed.
            u9No decoder installed for YAML. Install the PyYAML libraryN(R(targstkwargs((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyt
not_availableCs(tyamlRWR4t	safe_dumpt	safe_loadtImportErrorR$(R]R\((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyt
register_yaml5s
	icC@stt|ƒƒS(N(RR
(R((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytunpicklePscC@s2tjd„}tjd|tddddƒdS(upRegister pickle serializer.

    The fastest serialization method, but restricts
    you to python clients.
    cS@s||dtƒS(Ntprotocol(tpickle_protocol(tobjtdumper((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytpickle_dumps]supickleR2uapplication/x-python-serializeR3ubinaryN(tpickleRERWR4Rb(Rg((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytregister_pickleWsc@sÃd}}yiddl}|jdkr_ddlm‰m‰‡fd†}‡fd†}nd„}|}}Wn*ttfk
rŸd„}|}}nXtjd	||d
ddd
ƒdS(uYRegister msgpack serializer.

    See Also:
        http://msgpack.sourceforge.net/.
    iNi(tpackbtunpackbc@sˆ|dtƒS(Ntuse_bin_type(tTrue(R(Rj(sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytpackqsc@sˆ|ddƒS(Ntencodinguutf-8((R(Rk(sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytunpacktsc_@stdƒ‚dS(Nu(msgpack requires msgpack-python >= 0.4.0(R(RZR[((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytversion_mismatchwsc_@stdƒ‚dS(NuKNo decoder installed for msgpack. Please install the msgpack-python library(R(RZR[((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyR\|sumsgpackR2uapplication/x-msgpackR3ubinary(ii(	R$tmsgpacktversionRjRkR`t
ValueErrorRWR4(RnRpRrRqR\((RjRksH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytregister_msgpackes 
		ujsonuyamlumsgpackuapplication/jsonuapplication/x-yamluapplication/x-python-serializeuapplication/x-msgpackcC@s:x3|D]+}ytj|ƒWqtk
r1qXqWdS(uíEnable serializers that are considered to be unsafe.

    Note:
        Will enable ``pickle``, ``yaml`` and ``msgpack`` by default, but you
        can also specify a list of serializers (by name or content type)
        to enable.
    N(RWR6R:(tchoicestchoice((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytenable_insecure_serializersžs


cC@sRxtjD]}tj|ƒq
W|dk	rNx|D]}tj|ƒq4WndS(uADisable untrusted serializers.

    Will disable all serializers except ``json``
    or you can specify a list of deserializers to allow.

    Note:
        Producers will still be able to serialize data
        in these formats, but consumers will not accept
        incoming data using the untrusted content types.
    N(RWR#R8R$R6(tallowedR/((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytdisable_insecure_serializers­s

ukombu.serializersc@s$|dk	r ‡fd†|DƒS|S(Nc@s,h|]"}d|kr|nˆ|’qS(u/((t.0tn(R+(sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pys	<setcomp>És	(R$(tlR+((R+sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pytprepare_accept_contentÇs(ucontent_typeucontent_encodinguencoder(KRRt
__future__RRRtosRRhtpypickletcPickletcpickleR`R$tcollectionsRt
contextlibRtioRt
exceptionsRRRRtfiveR	R
tutils.compatRtutils.encodingRR
Rt__all__t	frozensetRHRTtplatformt
startswithRRLRtpickle_loadtinttenvironR?RdR.t	ExceptionRRR tobjectR!RWRERMR4R<R>RYRatversion_infoRbRiRuR=t
_setupfunsRxRztepRZR/R+R~(((sH/home/tvault/.virtenv/lib/python2.7/site-packages/kombu/serialization.pyt<module>s€

"				Ö						
					$