Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/itsdangerous/__pycache__/serializer.cpython-37.pyc

129 lines
7.8 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>/<2F>]<5D>!<00>@slddlZddlmZddlmZddlmZddlmZddlm Z ddl
m Z d d
<EFBFBD>Z Gd d <0C>d e <0A>ZdS) <0A>N<>)<01> text_type)<01>json)<01>
want_bytes)<01>
BadPayload)<01> BadSignature)<01>SignercCst|<00>i<00>t<02>S)z5Checks whether a serializer generates text or binary.)<03>
isinstance<EFBFBD>dumpsr)<01>
serializer<EFBFBD>r <00>A/tmp/pip-install-c3kgu56x/itsdangerous/itsdangerous/serializer.py<70>is_text_serializer src@s<>eZdZdZeZeZdej igZ
ddd<06>Z ddd<08>Z d d
<EFBFBD>Z dd d <0C>Zd d d<0E>Zd!dd<10>Zd"dd<12>Zd#dd<14>Zd$dd<16>Zd%dd<18>Zd&dd<1A>Zdd<1C>ZdS)'<27>
Serializera<EFBFBD>This class provides a serialization interface on top of the
signer. It provides a similar API to json/pickle and other modules
but is structured differently internally. If you want to change the
underlying implementation for parsing and loading you have to
override the :meth:`load_payload` and :meth:`dump_payload`
functions.
This implementation uses simplejson if available for dumping and
loading and will fall back to the standard library's json module if
it's not available.
You do not need to subclass this class in order to switch out or
customize the :class:`.Signer`. You can instead pass a different
class to the constructor as well as keyword arguments as a dict that
should be forwarded.
.. code-block:: python
s = Serializer(signer_kwargs={'key_derivation': 'hmac'})
You may want to upgrade the signing parameters without invalidating
existing signatures that are in use. Fallback signatures can be
given that will be tried if unsigning with the current signer fails.
Fallback signers can be defined by providing a list of
``fallback_signers``. Each item can be one of the following: a
signer class (which is instantiated with ``signer_kwargs``,
``salt``, and ``secret_key``), a tuple
``(signer_class, signer_kwargs)``, or a dict of ``signer_kwargs``.
For example, this is a serializer that signs using SHA-512, but will
unsign using either SHA-512 or SHA1:
.. code-block:: python
s = Serializer(
signer_kwargs={"digest_method": hashlib.sha512},
fallback_signers=[{"digest_method": hashlib.sha1}]
)
.. versionchanged:: 0.14:
The ``signer`` and ``signer_kwargs`` parameters were added to
the constructor.
.. versionchanged:: 1.1.0:
Added support for ``fallback_signers`` and configured a default
SHA-512 fallback. This fallback is for users who used the yanked
1.0.0 release which defaulted to SHA-512.
Z digest_method<6F> itsdangerousNcCszt|<01>|_t|<02>|_|dkr"|j}||_t|<03>|_|dkr@|j}||_|pLi|_|dkrft |j
pbd<01>}||_ |pri|_ dS)Nr ) r<00>
secret_key<EFBFBD>salt<6C>default_serializerr r<00>default_signer<65>signer<65> signer_kwargs<67>list<73>default_fallback_signers<72>fallback_signers<72>serializer_kwargs)<08>selfrrr rrrrr r r <00>__init__Ps



zSerializer.__init__c
Csj|dkr|j}|j}nt|<02>}y|r.|<01>d<02>}|<02>|<01>Stk
rd}ztd|d<04><02>Wdd}~XYnXdS)aLoads the encoded object. This function raises
:class:`.BadPayload` if the payload is not valid. The
``serializer`` parameter can be used to override the serializer
stored on the class. The encoded ``payload`` should always be
bytes.
Nzutf-8zSCould not load the payload because an exception occurred on unserializing the data.)<01>original_error)r r<00>decode<64>loads<64> Exceptionr)r<00>payloadr Zis_text<78>er r r <00> load_payloadis

zSerializer.load_payloadcCst|jj|f|j<03><01>S)z<>Dumps the encoded object. The return value is always bytes.
If the internal serializer returns text, the value will be
encoded as UTF-8.
)rr r
r)r<00>objr r r <00> dump_payload<61>szSerializer.dump_payloadcCs(|dkr|j}|j|jfd|i|j<03><02>S)z<>Creates a new instance of the signer to be used. The default
implementation uses the :class:`.Signer` base class.
Nr)rrrr)rrr r r <00> make_signer<65>szSerializer.make_signerccsz|dkr|j}|<00>|<01>VxZ|jD]P}t|<02>tkr>|}|j}nt|<02>tkrT|\}}n|j}||jfd|i|<03><02>Vq"WdS)z<>Iterates over all signers to be tried for unsigning. Starts
with the configured signer, then constructs each signer
specified in ``fallback_signers``.
Nr) rr&r<00>type<70>dictr<00>tuplerr)rr<00>fallback<63>kwargsr r r <00>iter_unsigners<72>s    
zSerializer.iter_unsignerscCs2t|<00>|<01><01>}|<00>|<02><01>|<03>}|jr.|<04>d<01>}|S)z<>Returns a signed string serialized with the internal
serializer. The return value can be either a byte or unicode
string depending on the format of the internal serializer.
zutf-8)rr%r&<00>signrr)rr$rr!<00>rvr r r r
<00>s

zSerializer.dumpscCs|<02>|<00>||<03><02>dS)z<>Like :meth:`dumps` but dumps into a file. The file handle has
to be compatible with what the internal serializer expects.
N)<02>writer
)rr$<00>frr r r <00>dump<6D>szSerializer.dumpc Cs`t|<01>}d}xJ|<00>|<02>D]<}y|<00>|<04>|<01><01>Stk
rR}z|}Wdd}~XYqXqW|<03>dS)ziReverse of :meth:`dumps`. Raises :exc:`.BadSignature` if the
signature validation fails.
N)rr,r#Zunsignr)r<00>srZlast_exceptionr<00>errr r r r<00>szSerializer.loadscCs|<00>|<01><01>|<02>S)z)Like :meth:`loads` but loads from a file.)r<00>read)rr0rr r r <00>load<61>szSerializer.loadcCs |<00>||<02>S)a9Like :meth:`loads` but without verifying the signature. This
is potentially very dangerous to use depending on how your
serializer works. The return value is ``(signature_valid,
payload)`` instead of just the payload. The first item will be a
boolean that indicates if the signature is valid. This function
never fails.
Use it for debugging only and if you know that your serializer
module is not exploitable (for example, do not use it with a
pickle serializer).
.. versionadded:: 0.15
)<01>_loads_unsafe_impl)rr2rr r r <00> loads_unsafe<66>szSerializer.loads_unsafec Cs<>yd|j|fd|i|pi<00><02>fStk
r|}z@|jdkr>dSyd|j|jf|pRi<00>fStk
rjdSXWdd}~XYnXdS)zfLow level helper function to implement :meth:`loads_unsafe`
in serializer subclasses.
TrN)FNF)rrr!r#r)rr2rZ load_kwargsZload_payload_kwargsr"r r r r6<00>s
zSerializer._loads_unsafe_implcOs|j|<01><01>f|<02>|<03>S)zYLike :meth:`loads_unsafe` but loads from a file.
.. versionadded:: 0.15
)r7r4)rr0<00>argsr+r r r <00> load_unsafe<66>szSerializer.load_unsafe)rNNNNN)N)N)N)N)N)N)N)N)NN)<17>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__rrrr<00>hashlib<69>sha512rrr#r%r&r,r
r1rr5r7r6r9r r r r rs*1 







r)r><00>_compatr<00>_jsonr<00>encodingr<00>excrrrrr<00>objectrr r r r <00><module>s