U aT @sddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z Gd d d e ZGd d d ee ZGd ddee ZdS)N) _CompactJSON) base64_decode) base64_encode) BadPayload) Serializer)TimedSerializercs\eZdZdZeZddeejej ejejejdfddZ ejedfdd Z Z S) URLSafeSerializerMixinzMixed in with a regular serializer it will attempt to zlib compress the string to make it shorter if necessary. It will also base64 encode the string so that it can safely be placed in a URL. N) serializer)payloadargsr kwargsreturnc sd}|dr|dd}d}z t|}Wn.tk rX}ztd|dW5d}~XYnX|rzt|}Wn.tk r}ztd|dW5d}~XYnXtj|f||S)NF.rTz;Could not base64 decode the payload because of an exception)original_errorzACould not zlib decompress the payload before decoding the payload) startswithr Exceptionrzlib decompresssuper load_payload)selfr r r r rjsone __class__VC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-w3tduf5e\itsdangerous\url_safe.pyrs(   z#URLSafeSerializerMixin.load_payload)objrcsNt|}d}t|}t|t|dkr6|}d}t|}|rJd|}|S)NFrTr)r dump_payloadrcompresslenr)rrrZ is_compressed compressedZbase64drrrr4s  z#URLSafeSerializerMixin.dump_payload) __name__ __module__ __qualname____doc__rZdefault_serializerbytes_tAnyOptionalrr __classcell__rrrrr s  r c@seZdZdZdS)URLSafeSerializerzWorks like :class:`.Serializer` but dumps and loads into a URL safe string consisting of the upper and lowercase character of the alphabet as well as ``'_'``, ``'-'`` and ``'.'``. Nr#r$r%r&rrrrr,Esr,c@seZdZdZdS)URLSafeTimedSerializerzWorks like :class:`.TimedSerializer` but dumps and loads into a URL safe string consisting of the upper and lowercase character of the alphabet as well as ``'_'``, ``'-'`` and ``'.'``. Nr-rrrrr.Lsr.)typingr(r_jsonrencodingrrexcrr rZtimedrr r,r.rrrrs      9