ó
 `¾Tc           @   s0  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z e j	 d d k Z
 e
 r± d d l m Z e Z e Z e e e f Z n= d d l m Z e Z e Z e j d d	 d
 ƒ Z e e f Z y d d l Z Wn e k
 rd d l Z n Xd e f d „  ƒ  YZ e ƒ  Z d Z  d d d „ Z! d „  Z" e# e d d ƒ Z% d „  Z& d e' f d „  ƒ  YZ( d e( f d „  ƒ  YZ) d e( f d „  ƒ  YZ* d e* f d „  ƒ  YZ+ d e* f d „  ƒ  YZ, d e+ f d „  ƒ  YZ- d  „  Z. d! „  Z/ d" „  Z0 d# „  Z1 d$ e f d% „  ƒ  YZ2 d& e2 f d' „  ƒ  YZ3 d( e2 f d) „  ƒ  YZ4 d* e f d+ „  ƒ  YZ5 d, e5 f d- „  ƒ  YZ6 d. e f d/ „  ƒ  YZ7 d0 e7 f d1 „  ƒ  YZ8 d2 e7 f d3 „  ƒ  YZ9 d4 e9 f d5 „  ƒ  YZ: d6 e f d7 „  ƒ  YZ; d8 e; e7 f d9 „  ƒ  YZ< d: e; e8 f d; „  ƒ  YZ= d S(<   s  
    itsdangerous
    ~~~~~~~~~~~~

    A module that implements various functions to deal with untrusted
    sources.  Mainly useful for web applications.

    :copyright: (c) 2014 by Armin Ronacher and the Django Software Foundation.
    :license: BSD, see LICENSE for more details.
iÿÿÿÿN(   t   datetimei    i   (   t   izip(   t   reducet   to_bytesi   t   bigt   _CompactJSONc           B   s    e  Z d  Z d „  Z d „  Z RS(   s6   Wrapper around simplejson that strips whitespace.
    c         C   s   t  j | ƒ S(   N(   t   jsont   loads(   t   selft   payload(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   /   s    c         C   s   t  j | d d ƒS(   Nt
   separatorst   ,t   :(   R   R   (   R   t   dumps(   R   t   obj(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   2   s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   +   s   	i€nMs   utf-8t   strictc         C   s(   t  |  t ƒ r$ |  j | | ƒ }  n  |  S(   N(   t
   isinstancet	   text_typet   encode(   t   st   encodingt   errors(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt
   want_bytes=   s    c         C   s   t  |  j i  ƒ t ƒ S(   s6   Checks wheather a serializer generates text or binary.(   R   R   R   (   t
   serializer(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   is_text_serializerC   s    t   compare_digestc         C   s–   t  d k	 r t  |  | ƒ St |  ƒ t | ƒ k } | rF d } |  } n d } | } x7 t t | ƒ t | ƒ ƒ D] \ } } | | | AO} qn W| d k S(   s8  Returns True if the two strings are equal, False otherwise.

    The time taken is independent of the number of characters that match.  Do
    not use this function for anything else than comparision with known
    length targets.

    This is should be implemented in C in order to get it completely right.
    i    i   N(   t   _builtin_constant_time_comparet   Nonet   lenR   t	   bytearray(   t   val1t   val2t   len_eqt   resultt   leftt   xt   y(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   constant_time_compareM   s    		(t   BadDatac           B   s>   e  Z d  Z d Z d „  Z d „  Z e r< e Z d „  Z n  RS(   sŸ   Raised if bad data of any sort was encountered.  This is the
    base for all exceptions that itsdangerous is currently using.

    .. versionadded:: 0.15
    c         C   s   t  j |  | ƒ | |  _ d  S(   N(   t	   Exceptiont   __init__t   message(   R   R,   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR+   l   s    c         C   s   t  |  j ƒ S(   N(   R   R,   (   R   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   __str__p   s    c         C   s   |  j  ƒ  j d ƒ S(   Ns   utf-8(   t   __unicode__R   (   R   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR-   u   s    N(	   R   R   R   R   R,   R+   R-   t   PY2R.   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR)   d   s   		t
   BadPayloadc           B   s   e  Z d  Z d d „ Z RS(   sÄ  This error is raised in situations when payload is loaded without
    checking the signature first and an exception happend as a result of
    that.  The original exception that caused that will be stored on the
    exception as :attr:`original_error`.

    This can also happen with a :class:`JSONWebSignatureSerializer` that
    is subclassed and uses a different serializer for the payload than
    the expected one.

    .. versionadded:: 0.15
    c         C   s   t  j |  | ƒ | |  _ d  S(   N(   R)   R+   t   original_error(   R   R,   R1   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR+   †   s    N(   R   R   R   R   R+   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR0   y   s   t   BadSignaturec           B   s   e  Z d  Z d d „ Z RS(   sÉ   This error is raised if a signature does not match.  As of
    itsdangerous 0.14 there are helpful attributes on the exception
    instances.  You can also catch down the baseclass :exc:`BadData`.
    c         C   s   t  j |  | ƒ | |  _ d  S(   N(   R)   R+   R	   (   R   R,   R	   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR+   “   s    N(   R   R   R   R   R+   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR2      s   t   BadTimeSignaturec           B   s   e  Z d  Z d d d „ Z RS(   s†   Raised for time based signatures that fail.  This is a subclass
    of :class:`BadSignature` so you can catch those down as well.
    c         C   s    t  j |  | | ƒ | |  _ d  S(   N(   R2   R+   t   date_signed(   R   R,   R	   R4   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR+   ¢   s    N(   R   R   R   R   R+   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR3      s   t	   BadHeaderc           B   s    e  Z d  Z d d d d „ Z RS(   s¯   Raised if a signed header is invalid in some form.  This only
    happens for serializers that have a header that goes with the
    signature.

    .. versionadded:: 0.24
    c         C   s)   t  j |  | | ƒ | |  _ | |  _ d  S(   N(   R2   R+   t   headerR1   (   R   R,   R	   R6   R1   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR+   µ   s    	N(   R   R   R   R   R+   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR5   ­   s   t   SignatureExpiredc           B   s   e  Z d  Z RS(   s¤   Signature timestamp is older than required max_age.  This is a
    subclass of :exc:`BadTimeSignature` so you can use the baseclass for
    catching the error.
    (   R   R   R   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR7   Â   s   c         C   s"   t  |  ƒ }  t j |  ƒ j d ƒ S(   s¢   base64 encodes a single bytestring (and is tolerant to getting
    called with a unicode string).
    The resulting bytestring is safe for putting into URLs.
    t   =(   R   t   base64t   urlsafe_b64encodet   strip(   t   string(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   base64_encodeÉ   s    c         C   s8   t  |  d d d d ƒ}  t j |  d t |  ƒ d ƒ S(   s‹   base64 decodes a single bytestring (and is tolerant to getting
    called with a unicode string).
    The result is also a bytestring.
    R   t   asciiR   t   ignoreR8   i   (   R   R9   t   urlsafe_b64decodeR   (   R<   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   base64_decodeÒ   s    c         C   sY   |  d k s t  ‚ g  } x+ |  rE | j t |  d @ƒ ƒ |  d L}  q Wd j t | ƒ ƒ S(   Ni    iÿ   i   t    (   t   AssertionErrort   appendt   int_to_bytet   joint   reversed(   t   numt   rv(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   int_to_bytesÛ   s    	c         C   s   t  d „  t |  ƒ d ƒ S(   Nc         S   s   |  d >| BS(   Ni   (    (   t   at   b(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   <lambda>å   s    i    (   R   R    (   t   bytestr(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   bytes_to_intä   s    t   SigningAlgorithmc           B   s    e  Z d  Z d „  Z d „  Z RS(   sz   Subclasses of `SigningAlgorithm` have to implement `get_signature` to
    provide signature generation functionality.
    c         C   s   t  ƒ  ‚ d S(   s1   Returns the signature for the given key and valueN(   t   NotImplementedError(   R   t   keyt   value(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   get_signatureí   s    c         C   s   t  | |  j | | ƒ ƒ S(   s;   Verifies the given signature matches the expected signature(   R(   RT   (   R   RR   RS   t   sig(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   verify_signatureñ   s    (   R   R   R   RT   RV   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRP   è   s   	t   NoneAlgorithmc           B   s   e  Z d  Z d „  Z RS(   sj   This class provides a algorithm that does not perform any signing and
    returns an empty signature.
    c         C   s   d S(   NRB   (    (   R   RR   RS   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRT   û   s    (   R   R   R   RT   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRW   ö   s   t   HMACAlgorithmc           B   s2   e  Z d  Z e e j ƒ Z d d „ Z d „  Z	 RS(   s5   This class provides signature generation using HMACs.c         C   s%   | d  k r |  j } n  | |  _ d  S(   N(   R   t   default_digest_methodt   digest_method(   R   RZ   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR+     s    c         C   s(   t  j | d | d |  j ƒ} | j ƒ  S(   Nt   msgt	   digestmod(   t   hmact   newRZ   t   digest(   R   RR   RS   t   mac(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRT     s    N(
   R   R   R   t   staticmethodt   hashlibt   sha1RY   R   R+   RT   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRX   ÿ   s   t   Signerc           B   sq   e  Z d  Z e e j ƒ Z d Z d
 d d
 d
 d
 d „ Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d	 „  Z RS(   så  This class can sign bytes and unsign it and validate the signature
    provided.

    Salt can be used to namespace the hash, so that a signed string is only
    valid for a given namespace.  Leaving this at the default value or re-using
    a salt value across different parts of your application where the same
    signed value in one part can mean something different in another part
    is a security risk.

    See :ref:`the-salt` for an example of what the salt is doing and how you
    can utilize it.

    .. versionadded:: 0.14
       `key_derivation` and `digest_method` were added as arguments to the
       class constructor.

    .. versionadded:: 0.18
        `algorithm` was added as an argument to the class constructor.
    s   django-concatt   .c         C   s    t  | ƒ |  _ | |  _ | d  k r* d n | |  _ | d  k rK |  j } n  | |  _ | d  k rl |  j } n  | |  _ | d  k r“ t	 |  j ƒ } n  | |  _
 d  S(   Ns   itsdangerous.Signer(   R   t
   secret_keyt   sepR   t   saltt   default_key_derivationt   key_derivationRY   RZ   RX   t	   algorithm(   R   Rf   Rh   Rg   Rj   RZ   Rk   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR+   3  s    			c         C   sÌ   t  |  j ƒ } |  j d k r8 |  j | |  j ƒ j ƒ  S|  j d k re |  j | d |  j ƒ j ƒ  S|  j d k r¦ t j |  j d |  j ƒ} | j | ƒ | j ƒ  S|  j d k r¼ |  j St	 d ƒ ‚ d S(	   sn  This method is called to derive the key.  If you're unhappy with
        the default key derivation choices you can override them here.
        Keep in mind that the key derivation in itsdangerous is not intended
        to be used as a security method to make a complex key out of a short
        password.  Instead you should use large random secret keys.
        t   concats   django-concatt   signerR]   R\   t   nones   Unknown key derivation methodN(
   R   Rh   Rj   RZ   Rf   R_   R]   R^   t   updatet	   TypeError(   R   Rh   R`   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt
   derive_keyB  s    
c         C   s7   t  | ƒ } |  j ƒ  } |  j j | | ƒ } t | ƒ S(   s)   Returns the signature for the given value(   R   Rq   Rk   RT   R=   (   R   RS   RR   RU   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRT   X  s    c         C   s   | t  |  j ƒ |  j | ƒ S(   s   Signs the given string.(   R   Rg   RT   (   R   RS   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   sign_  s    c         C   sG   |  j  ƒ  } y t | ƒ } Wn t k
 r0 t SX|  j j | | | ƒ S(   s+   Verifies the signature for the given value.(   Rq   RA   R*   t   FalseRk   RV   (   R   RS   RU   RR   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRV   c  s    c         C   s…   t  | ƒ } t  |  j ƒ } | | k r= t d |  j ƒ ‚ n  | j | d ƒ \ } } |  j | | ƒ rk | St d | d | ƒ‚ d S(   s   Unsigns the given string.s   No %r found in valuei   s   Signature %r does not matchR	   N(   R   Rg   R2   t   rsplitRV   (   R   t   signed_valueRg   RS   RU   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   unsignl  s    c         C   s.   y |  j  | ƒ t SWn t k
 r) t SXd S(   sw   Just validates the given signed value.  Returns `True` if the
        signature exists and is valid, `False` otherwise.N(   Rv   t   TrueR2   Rs   (   R   Ru   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   validatex  s
    N(   R   R   R   Ra   Rb   Rc   RY   Ri   R   R+   Rq   RT   Rr   RV   Rv   Rx   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRd     s   							t   TimestampSignerc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d e d „ Z d d „ Z	 RS(   s8  Works like the regular :class:`Signer` but also records the time
    of the signing and can be used to expire signatures.  The unsign
    method can rause a :exc:`SignatureExpired` method if the unsigning
    failed because the signature is expired.  This exception is a subclass
    of :exc:`BadSignature`.
    c         C   s   t  t j ƒ  t ƒ S(   sŽ   Returns the current timestamp.  This implementation returns the
        seconds since 1/1/2011.  The function must return an integer.
        (   t   intt   timet   EPOCH(   R   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   get_timestampŠ  s    c         C   s   t  j | t ƒ S(   s[   Used to convert the timestamp from `get_timestamp` into a
        datetime object.
        (   R    t   utcfromtimestampR|   (   R   t   ts(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   timestamp_to_datetime  s    c         C   sV   t  | ƒ } t t |  j ƒ  ƒ ƒ } t  |  j ƒ } | | | } | | |  j | ƒ S(   s<   Signs the given string and also attaches a time information.(   R   R=   RJ   R}   Rg   RT   (   R   RS   t	   timestampRg   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRr   –  s
    c   
      C   s’  y t  j |  | ƒ } d } Wn( t k
 rF } | } | j p@ d } n Xt |  j ƒ } | | k r† | rq | ‚ n  t d d | ƒ‚ n  | j | d ƒ \ } } y t	 t
 | ƒ ƒ } Wn t k
 rÍ d } n X| d k	 rû t t | ƒ d | d | ƒ‚ n  | d k rt d d | ƒ‚ n  | d k	 ru|  j ƒ  | }	 |	 | k rut d |	 | f d | d |  j | ƒ ƒ‚ qun  | rŽ| |  j | ƒ f S| S(	   s@  Works 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 set to `True`
        the timestamp of the signature will be returned as naive
        :class:`datetime.datetime` object in UTC.
        RB   s   timestamp missingR	   i   R4   s   Malformed timestamps   Signature age %s > %s secondsN(   Rd   Rv   R   R2   R	   R   Rg   R3   Rt   RO   RA   R*   R   R}   R7   R€   (
   R   RS   t   max_aget   return_timestampR$   t	   sig_errort   eRg   R   t   age(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRv   ž  s>    
	
c         C   s4   y |  j  | d | ƒt SWn t k
 r/ t SXd S(   sw   Just validates the given signed value.  Returns `True` if the
        signature exists and is valid, `False` otherwise.R‚   N(   Rv   Rw   R2   Rs   (   R   Ru   R‚   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRx   Õ  s
    N(
   R   R   R   R}   R€   Rr   R   Rs   Rv   Rx   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRy   ‚  s   			7t
   Serializerc           B   s¤   e  Z d  Z e Z e Z d d d d d „ Z d d „ Z	 d „  Z
 d d „ Z d d „ Z d d „ Z d d „ Z d d	 „ Z d d
 „ Z d d d „ Z d „  Z RS(   sÏ  This class provides a serialization interface on top of the
    signer.  It provides a similar API to json/pickle and other modules but is
    slightly differently structured 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.

    Starting with 0.14 you do not need to subclass this class in order to
    switch out or customer the :class:`Signer`.  You can instead also pass a
    different class to the constructor as well as keyword arguments as
    dictionary that should be forwarded::

        s = Serializer(signer_kwargs={'key_derivation': 'hmac'})

    .. versionchanged:: 0.14:
       The `signer` and `signer_kwargs` parameters were added to the
       constructor.
    t   itsdangerousc         C   s‚   t  | ƒ |  _ t  | ƒ |  _ | d  k r6 |  j } n  | |  _ t | ƒ |  _ | d  k rf |  j } n  | |  _ | px i  |  _	 d  S(   N(
   R   Rf   Rh   R   t   default_serializerR   R   t   default_signerRm   t   signer_kwargs(   R   Rf   Rh   R   Rm   R‹   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR+      s    		c         C   s‚   | d k r! |  j } |  j } n t | ƒ } y) | rH | j d ƒ } n  | j | ƒ SWn% t k
 r} } t d d | ƒ‚ n Xd S(   s  Loads 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 is
        always byte based.
        s   utf-8sR   Could not load the payload because an exception occurred on unserializing the dataR1   N(   R   R   R   t   decodeR   R*   R0   (   R   R	   R   t   is_textR…   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   load_payload  s    		c         C   s   t  |  j j | ƒ ƒ S(   s¸   Dumps the encoded object.  The return value is always a
        bytestring.  If the internal serializer is text based the value
        will automatically be encoded to utf-8.
        (   R   R   R   (   R   R   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   dump_payload!  s    c         C   s4   | d k r |  j } n  |  j |  j d | |  j S(   sŽ   A method that creates a new instance of the signer to be used.
        The default implementation uses the :class:`Signer` baseclass.
        Rh   N(   R   Rh   Rm   Rf   R‹   (   R   Rh   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   make_signer(  s    c         C   sL   t  |  j | ƒ ƒ } |  j | ƒ j | ƒ } |  j rH | j d ƒ } n  | S(   sÅ   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.
        s   utf-8(   R   R   R   Rr   R   RŒ   (   R   R   Rh   R	   RI   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   0  s
    	c         C   s   | j  |  j | | ƒ ƒ d S(   s‹   Like :meth:`dumps` but dumps into a file.  The file handle has
        to be compatible with what the internal serializer expects.
        N(   t   writeR   (   R   R   t   fRh   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   dump;  s    c         C   s+   t  | ƒ } |  j |  j | ƒ j | ƒ ƒ S(   sh   Reverse of :meth:`dumps`, raises :exc:`BadSignature` if the
        signature validation fails.
        (   R   RŽ   R   Rv   (   R   R   Rh   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   A  s    c         C   s   |  j  | j ƒ  | ƒ S(   s)   Like :meth:`loads` but loads from a file.(   R   t   read(   R   R’   Rh   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   loadH  s    c         C   s   |  j  | | ƒ S(   sE  Like :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_okay, payload)`` instead of
        just the payload.  The first item will be a boolean that indicates
        if the signature is okay (``True``) or if it failed.  This function
        never fails.

        Use it for debugging only and if you know that your serializer module
        is not exploitable (eg: do not use it with a pickle serializer).

        .. versionadded:: 0.15
        (   t   _loads_unsafe_impl(   R   R   Rh   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   loads_unsafeL  s    c         C   s—   y& t  |  j | d | | p i  f SWnj t k
 r’ } | j d k rQ t d f Sy# t |  j | j | pl i   f SWq“ t k
 rŽ t d f SXn Xd S(   se   Lowlevel helper function to implement :meth:`loads_unsafe` in
        serializer subclasses.
        Rh   N(   Rw   R   R2   R	   R   Rs   RŽ   R0   (   R   R   Rh   t   load_kwargst   load_payload_kwargsR…   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR–   [  s    &
c         O   s   |  j  | j ƒ  | | Ž S(   sY   Like :meth:`loads_unsafe` but loads from a file.

        .. versionadded:: 0.15
        (   R—   R”   (   R   R’   t   argst   kwargs(    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   load_unsafek  s    N(   R   R   R   R   R‰   Rd   RŠ   R   R+   RŽ   R   R   R   R“   R   R•   R—   R–   Rœ   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR‡   ß  s    	t   TimedSerializerc           B   s5   e  Z d  Z e Z d e d d „ Z d d d „ Z RS(   sQ   Uses the :class:`TimestampSigner` instead of the default
    :meth:`Signer`.
    c         C   sJ   |  j  | ƒ j | | d t ƒ\ } } |  j | ƒ } | rF | | f S| S(   s°  Reverse 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
        which is a subclass of :exc:`BadSignature`.  All arguments are
        forwarded to the signer's :meth:`~TimestampSigner.unsign` method.
        Rƒ   (   R   Rv   Rw   RŽ   (   R   R   R‚   Rƒ   Rh   t   base64dR   R	   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   z  s    
c         C   s)   i | d 6} i  } |  j  | | | | ƒ S(   NR‚   (   R–   (   R   R   R‚   Rh   R˜   R™   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR—   ‰  s    N(	   R   R   R   Ry   RŠ   R   Rs   R   R—   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   s  s   t   JSONWebSignatureSerializerc           B   sÕ   e  Z d  Z i e e j ƒ d 6e e j ƒ d 6e e j ƒ d 6e ƒ  d 6Z	 d Z
 e Z d d d d d d „ Z e d „ Z d „  Z d „  Z d d d	 „ Z d
 „  Z d d d „ Z d e d „ Z d e d „ Z RS(   ss   This serializer implements JSON Web Signature (JWS) support.  Only
    supports the JWS Compact Serialization.
    t   HS256t   HS384t   HS512Rn   c         C   sS   t  j |  | | | | | ƒ | d  k r4 |  j } n  | |  _ |  j | ƒ |  _ d  S(   N(   R‡   R+   R   t   default_algorithmt   algorithm_namet   make_algorithmRk   (   R   Rf   Rh   R   Rm   R‹   R¤   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR+      s    
	c   	      C   s=  t  | ƒ } d | k r' t d ƒ ‚ n  | j d d ƒ \ } } y t | ƒ } Wn% t k
 rv } t d d | ƒ‚ n Xy t | ƒ } Wn% t k
 r® } t d d | ƒ‚ n Xy t j |  | d t ƒ} Wn% t	 k
 rò } t d d | ƒ‚ n Xt
 | t ƒ st d	 d
 | ƒ‚ n  t j |  | ƒ } | r9| | f S| S(   NRe   s   No "." found in valuei   s:   Could not base64 decode the header because of an exceptionR1   s;   Could not base64 decode the payload because of an exceptionR   s5   Could not unserialize header because it was malformeds#   Header payload is not a JSON objectR6   (   R   R0   t   splitRA   R*   R5   R‡   RŽ   R   R)   R   t   dict(	   R   R	   t   return_headert   base64d_headert   base64d_payloadt   json_headerR…   t   json_payloadR6   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRŽ   ©  s6    				
c         C   s<   t  |  j j | ƒ ƒ } t  |  j j | ƒ ƒ } | d | S(   NRe   (   R=   R   R   (   R   R6   R   R©   Rª   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   Æ  s    c         C   s3   y |  j  | SWn t k
 r. t d ƒ ‚ n Xd  S(   Ns   Algorithm not supported(   t   jws_algorithmst   KeyErrorRQ   (   R   R¤   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR¥   Ë  s    c      
   C   sp   | d  k r |  j } n  | d  k r* d n d  } | d  k rH |  j } n  |  j |  j d | d d d | d | ƒS(   NRn   Rh   Rg   Re   Rj   Rk   (   R   Rh   Rk   Rm   Rf   (   R   Rh   Rk   Rj   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   Ñ  s    c         C   s)   | r | j  ƒ  n i  } |  j | d <| S(   Nt   alg(   t   copyR¤   (   R   t   header_fieldsR6   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   make_headerÚ  s    c         C   s=   |  j  | ƒ } |  j | |  j ƒ } | j |  j | | ƒ ƒ S(   s¬   Like :meth:`~Serializer.dumps` but creates a JSON Web Signature.  It
        also allows for specifying additional fields to be included in the JWS
        Header.
        (   R²   R   Rk   Rr   R   (   R   R   Rh   R±   R6   Rm   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   ß  s    c         C   s€   |  j  |  j | |  j ƒ j t | ƒ ƒ d t ƒ\ } } | j d ƒ |  j k rl t d d | d | ƒ‚ n  | r| | | f S| S(   sy   Reverse of :meth:`dumps`. If requested via `return_header` it will
        return a tuple of payload and header.
        R¨   R¯   s   Algorithm mismatchR6   R	   (	   RŽ   R   Rk   Rv   R   Rw   t   getR¤   R5   (   R   R   Rh   R¨   R	   R6   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   è  s    $
c         C   s#   i | d 6} |  j  | | | | ƒ S(   NR¨   (   R–   (   R   R   Rh   R¨   R›   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR—   ö  s    N(   R   R   R   RX   Rb   t   sha256t   sha384t   sha512RW   R­   R£   t   compact_jsonR‰   R   R+   Rs   RŽ   R   R¥   R   R²   R   R   R—   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRŸ     s$   					t   TimedJSONWebSignatureSerializerc           B   sJ   e  Z d  Z d Z d d „ Z d „  Z d e d „ Z d „  Z	 d „  Z
 RS(   sz  Works like the regular :class:`JSONWebSignatureSerializer` but also
    records the time of the signing and can be used to expire signatures.

    JWS currently does not specify this behavior but it mentions a possibility
    extension like this in the spec.  Expiry date is encoded into the header
    similarily as specified in `draft-ietf-oauth-json-web-token
    <http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#expDef`_.

    The unsign method can raise a :exc:`SignatureExpired` method if the
    unsigning failed because the signature is expired.  This exception is a
    subclass of :exc:`BadSignature`.
    i  c         K   s8   t  j |  | |  | d  k r+ |  j } n  | |  _ d  S(   N(   RŸ   R+   R   t   DEFAULT_EXPIRES_INt
   expires_in(   R   Rf   Rº   R›   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR+     s    c         C   sC   t  j |  | ƒ } |  j ƒ  } | |  j } | | d <| | d <| S(   Nt   iatt   exp(   RŸ   R²   t   nowRº   (   R   R±   R6   R»   R¼   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR²     s    

c         C   sÈ   t  j |  | | d t ƒ\ } } d | k rB t d d | ƒ‚ n  t | d t ƒ ob | d d k sz t d d | ƒ‚ n  | d |  j ƒ  k  r´ t d d | d |  j | ƒ ƒ‚ n  | rÄ | | f S| S(	   NR¨   R¼   s   Missing expiry dateR	   i    s   expiry date is not an IntDates   Signature expiredR4   (	   RŸ   R   Rw   R2   R   t   number_typesR½   R7   t   get_issue_date(   R   R   Rh   R¨   R	   R6   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR     s    	
c         C   s5   | j  d ƒ } t | t ƒ r1 t j t | ƒ ƒ Sd  S(   NR»   (   R³   R   R¾   R    R~   Rz   (   R   R6   RI   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR¿   -  s    c         C   s   t  t j ƒ  ƒ S(   N(   Rz   R{   (   R   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR½   2  s    N(   R   R   R   R¹   R   R+   R²   Rs   R   R¿   R½   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR¸   û  s   		t   URLSafeSerializerMixinc           B   s    e  Z d  Z d „  Z d „  Z RS(   sÍ   Mixed 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.
    c         C   sº   t  } | j d ƒ r( | d } t } n  y t | ƒ } Wn% t k
 r_ } t d d | ƒ‚ n X| r¤ y t j | ƒ } Wq¤ t k
 r  } t d d | ƒ‚ q¤ Xn  t t	 |  ƒ j
 | ƒ S(   NRe   i   s;   Could not base64 decode the payload because of an exceptionR1   sA   Could not zlib decompress the payload before decoding the payload(   Rs   t
   startswithRw   RA   R*   R0   t   zlibt
   decompresst   superRÀ   RŽ   (   R   R	   RÃ   R   R…   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRŽ   <  s     
			c         C   s{   t  t |  ƒ j | ƒ } t } t j | ƒ } t | ƒ t | ƒ d k  rX | } t } n  t | ƒ } | rw d | } n  | S(   Ni   Re   (	   RÄ   RÀ   R   Rs   RÂ   t   compressR   Rw   R=   (   R   R   R   t   is_compressedt
   compressedRž   (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyR   N  s    	(   R   R   R   RŽ   R   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRÀ   6  s   	t   URLSafeSerializerc           B   s   e  Z d  Z e Z RS(   s¿   Works 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 ``'.'``.
    (   R   R   R   R·   R‰   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRÈ   [  s   t   URLSafeTimedSerializerc           B   s   e  Z d  Z e Z RS(   sÄ   Works 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 ``'.'``.
    (   R   R   R   R·   R‰   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyRÉ   c  s   (>   R   t   sysR]   RÂ   R{   R9   Rb   t   operatorR    t   version_infoR/   t	   itertoolsR   t   unicodeR   t   chrRE   Rz   t   longt   floatR¾   t	   functoolsR   t   zipt   strt   methodcallert
   simplejsonR   t   ImportErrort   objectR   R·   R|   R   R   t   getattrR   R   R(   R*   R)   R0   R2   R3   R5   R7   R=   RA   RJ   RO   RP   RW   RX   Rd   Ry   R‡   R   RŸ   R¸   RÀ   RÈ   RÉ   (    (    (    sR   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/itsdangerous.pyt   <module>   sh   											r]”l;%