/usr/local/lib/python3.6/site-packages/itsdangerous/__pycache__
NameSizeModeActions
encoding.cpython-36.pyc17940644editdlrm
exc.cpython-36.pyc33390644editdlrm
jws.cpython-36.pyc74520644editdlrm
serializer.cpython-36.pyc95150644editdlrm
signer.cpython-36.pyc83390644editdlrm
timed.cpython-36.pyc61920644editdlrm
url_safe.cpython-36.pyc26440644editdlrm
_json.cpython-36.pyc14900644editdlrm
__init__.cpython-36.pyc9720644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/itsdangerous/__pycache__/timed.cpython-36.pyc (6192B)
3 _TBg@sddlZddlZddlZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd l m Z dd l m Z dd l mZdd lmZddlmZejeefZejeZejeZejrddlZGdddeZGdddeZdS)N)datetime)timezone) base64_decode) base64_encode) bytes_to_int) int_to_bytes) want_bytes) BadSignature)BadTimeSignature)SignatureExpired) Serializer)SignercseZdZdZedddZeedddZee dd d Z e j dee d e dddZe j dee deje efdddZdee eejeje efe fdfdd Zdee edddZZS)TimestampSignerzWorks like the regular :class:`.Signer` but also records the time of the signing and can be used to expire signatures. The :meth:`unsign` method can raise :exc:`.SignatureExpired` if the unsigning failed because the signature is expired. )returncCs ttjS)zTReturns the current timestamp. The function must return an integer. )inttime)selfr:/tmp/pip-build-0s3hx122/itsdangerous/itsdangerous/timed.py get_timestamp!szTimestampSigner.get_timestamp)tsrcCstj|tjdS)a Convert the timestamp from :meth:`get_timestamp` into an aware :class`datetime.datetime` in UTC. .. versionchanged:: 2.0 The timestamp is returned as a timezone-aware ``datetime`` in UTC rather than a naive ``datetime`` assumed to be UTC. )tz)r fromtimestamprutc)rrrrrtimestamp_to_datetime'sz%TimestampSigner.timestamp_to_datetime)valuercCs@t|}tt|j}t|j}|||}|||j|S)z:Signs the given string and also attaches time information.)r rrrsepZ get_signature)rr timestamprrrrsign1s   zTimestampSigner.signNFz_te.Literal[False]) signed_valuemax_agereturn_timestamprcCsdS)Nr)rr r!r"rrrunsign<szTimestampSigner.unsignTz_te.Literal[True]cCsdS)Nr)rr r!r"rrrr#Esc sjytj|}d}Wn0tk rD}z|}|jp2d}WYdd}~XnXt|j}||krl|r`|td|d|j|d\}} d} d} ytt | } Wnt k rYnX|dk r| dk r|j | } tt ||| d| dkrtd|d|dk rR|j | } | |kr,td| d |d ||j | d| d krRtd| d ||j | d|rf||j | fS|S) aWorks like the regular :meth:`.Signer.unsign` but can also validate the time. See the base docstring of the class for the general behavior. If ``return_timestamp`` is ``True`` the timestamp of the signature will be returned as an aware :class:`datetime.datetime` object in UTC. .. versionchanged:: 2.0 The timestamp is returned as a timezone-aware ``datetime`` in UTC rather than a naive ``datetime`` assumed to be UTC. Nztimestamp missing)payloadr)r%Z date_signedzMalformed timestampzSignature age z > z secondsrz < 0 seconds)superr#r r%r rr rsplitrr Exceptionrstrrr ) rr r!r"resultZ sig_errorerrZts_bytesZts_intZts_dtZage) __class__rrr#NsN          )r r!rc Cs,y|j||ddStk r&dSXdS)zeOnly validates the given signed value. Returns ``True`` if the signature exists and is valid.)r!TFN)r#r )rr r!rrrvalidates zTimestampSigner.validate)NF)NT)NF)N)__name__ __module__ __qualname____doc__rrrr _t_str_bytesbytesrtypingZoverload _t_opt_intr#_tTupleboolUnionr- __classcell__rr)r,rrs   &Lrcs|eZdZUdZeZejed eej edfdd Z de e e eejddd Zde e eeje ejfd d d ZZS)TimedSerializerzOUses :class:`TimestampSigner` instead of the default :class:`.Signer`. N)saltrcstjdtj|S)Nz_t.Iterator[TimestampSigner])r6castr&iter_unsigners)rr<)r,rrr>szTimedSerializer.iter_unsignersF)sr!r"r<rc Cst|}d}x||j|D]n}y.|j||dd\}}|j|} |rH| |fS| Stk r`Yqtk r} z | }WYdd} ~ XqXqWtjt|dS)aReverse of :meth:`dumps`, raises :exc:`.BadSignature` if the signature validation fails. If a ``max_age`` is provided it will ensure the signature is not older than that time in seconds. In case the signature is outdated, :exc:`.SignatureExpired` is raised. All arguments are forwarded to the signer's :meth:`~TimestampSigner.unsign` method. NT)r!r")r r>r#Z load_payloadr r r6r=) rr?r!r"r<Zlast_exceptionsignerZbase64drr%errrrrloadss zTimedSerializer.loads)r?r!r<rcCs|j||d|idS)Nr!)Z load_kwargs)Z_loads_unsafe_impl)rr?r!r<rrr loads_unsafeszTimedSerializer.loads_unsafe)N)NFN)NN)r.r/r0r1rZdefault_signerr6Type_t_opt_str_bytesIteratorr>r2r5r8ZAnyrBr7rCr:rr)r,rr;s   "r;) rr4r6rrencodingrrrrr excr r r serializerr r@rr9r)r3r2OptionalrErr5Z TYPE_CHECKINGZtyping_extensionsZ_terr;rrrrs,