Your IP : 18.226.98.244


Current Path : /opt/alt/python34/lib64/python3.4/http/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/http/__pycache__/cookies.cpython-34.pyc

�
e f\R�
@sdZddlZddlZdddgZdjZdjZdjZGd	d�de�Z	ej
ejd
Zi�dd6d
d6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dKdL6dMdN6dOdP6dQdR6dSdT6dUdV6dWdX6dYdZ6d[d\6d]d^6d_d`6dadb6dcdd6dedf6dgdh6didj6dkdl6dmdn6dodp6dqdr6dsdt6dudv6dwdx6dydz6d{d|6d}d~6dd�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d6dd6dd6dd6dd6d	d
6dd6d
d6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dKdL6dMdN6dOdP6dQdR6dSdT6Z
edUdV�ZejdW�ZejdX�ZdYdZ�Zd[d\d]d^d_d`dagZddbdcdddedfdgdhdidjdkdldmg
Zdeedndo�ZGdpdq�dqe�ZdrZedsZejdteduedvej�ZGdwd�de�ZGdxd�de�ZdS(ya.

Here's a sample session to show how to use this module.
At the moment, this is the only documentation.

The Basics
----------

Importing is easy...

   >>> from http import cookies

Most of the time you start by creating a cookie.

   >>> C = cookies.SimpleCookie()

Once you've created your Cookie, you can add values just as if it were
a dictionary.

   >>> C = cookies.SimpleCookie()
   >>> C["fig"] = "newton"
   >>> C["sugar"] = "wafer"
   >>> C.output()
   'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer'

Notice that the printable representation of a Cookie is the
appropriate format for a Set-Cookie: header.  This is the
default behavior.  You can change the header and printed
attributes by using the .output() function

   >>> C = cookies.SimpleCookie()
   >>> C["rocky"] = "road"
   >>> C["rocky"]["path"] = "/cookie"
   >>> print(C.output(header="Cookie:"))
   Cookie: rocky=road; Path=/cookie
   >>> print(C.output(attrs=[], header="Cookie:"))
   Cookie: rocky=road

The load() method of a Cookie extracts cookies from a string.  In a
CGI script, you would use this method to extract the cookies from the
HTTP_COOKIE environment variable.

   >>> C = cookies.SimpleCookie()
   >>> C.load("chips=ahoy; vienna=finger")
   >>> C.output()
   'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'

The load() method is darn-tootin smart about identifying cookies
within a string.  Escaped quotation marks, nested semicolons, and other
such trickeries do not confuse it.

   >>> C = cookies.SimpleCookie()
   >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
   >>> print(C)
   Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"

Each element of the Cookie also supports all of the RFC 2109
Cookie attributes.  Here's an example which sets the Path
attribute.

   >>> C = cookies.SimpleCookie()
   >>> C["oreo"] = "doublestuff"
   >>> C["oreo"]["path"] = "/"
   >>> print(C)
   Set-Cookie: oreo=doublestuff; Path=/

Each dictionary element has a 'value' attribute, which gives you
back the value associated with the key.

   >>> C = cookies.SimpleCookie()
   >>> C["twix"] = "none for you"
   >>> C["twix"].value
   'none for you'

The SimpleCookie expects that all values should be standard strings.
Just to be sure, SimpleCookie invokes the str() builtin to convert
the value to a string, when the values are set dictionary-style.

   >>> C = cookies.SimpleCookie()
   >>> C["number"] = 7
   >>> C["string"] = "seven"
   >>> C["number"].value
   '7'
   >>> C["string"].value
   'seven'
   >>> C.output()
   'Set-Cookie: number=7\r\nSet-Cookie: string=seven'

Finis.
�N�CookieError�
BaseCookie�SimpleCookie�z; � c@seZdZdS)rN)�__name__�
__module__�__qualname__�r
r
�1/opt/alt/python34/lib64/python3.4/http/cookies.pyr�sz!#$%&'*+-.^_`|~:z\000�z\001�z\002�z\003�z\004�z\005�z\006�z\007�z\010�z\011�	z\012�
z\013�z\014�z\015�
z\016�z\017�z\020�z\021�z\022�z\023�z\024�z\025�z\026�z\027�z\030�z\031�z\032�z\033�z\034�z\035�z\036�z\037�z\054�,z\073�;z\"�"z\\�\z\177�z\200�€z\201�z\202�‚z\203�ƒz\204�„z\205�…z\206�†z\207�‡z\210�ˆz\211�‰z\212�Šz\213�‹z\214�Œz\215�z\216�Žz\217�z\220�z\221�‘z\222�’z\223�“z\224�”z\225�•z\226�–z\227�—z\230�˜z\231�™z\232�šz\233�›z\234�œz\235�z\236�žz\237�Ÿz\240� z\241�¡z\242�¢z\243�£z\244�¤z\245�¥z\246�¦z\247�§z\250�¨z\251�©z\252�ªz\253�«z\254�¬z\255�­z\256�®z\257�¯z\260�°z\261�±z\262�²z\263�³z\264�´z\265�µz\266�¶z\267�·z\270�¸z\271�¹z\272�ºz\273�»z\274�¼z\275�½z\276�¾z\277�¿z\300�Àz\301�Áz\302�Âz\303�Ãz\304�Äz\305�Åz\306�Æz\307�Çz\310�Èz\311�Éz\312�Êz\313�Ëz\314�Ìz\315�Íz\316�Îz\317�Ïz\320�Ðz\321�Ñz\322�Òz\323�Óz\324�Ôz\325�Õz\326�Öz\327�×z\330�Øz\331�Ùz\332�Úz\333�Ûz\334�Üz\335�Ýz\336�Þz\337�ßz\340�àz\341�áz\342�âz\343�ãz\344�äz\345�åz\346�æz\347�çz\350�èz\351�éz\352�êz\353�ëz\354�ìz\355�íz\356�îz\357�ïz\360�ðz\361�ñz\362�òz\363�óz\364�ôz\365�õz\366�öz\367�÷z\370�øz\371�ùz\372�úz\373�ûz\374�üz\375�ýz\376�þz\377�ÿcsFt�fdd�|D��r#|Sdtdd�|D��dSdS)z�Quote a string for use in a cookie header.

    If the string does not need to be double-quoted, then just return the
    string.  Otherwise, surround the string in doublequotes and quote
    (with a \) special characters.
    c3s|]}|�kVqdS)Nr
)�.0�c)�
LegalCharsr
r�	<genexpr>�sz_quote.<locals>.<genexpr>r.css!|]}tj||�VqdS)N)�_Translator�get)r��sr
r
rr��sN)�all�	_nulljoin)�strr�r
)r�r�_quote�sr�z\\[0-3][0-7][0-7]z[\\].cCs�t|�dkr|S|ddks6|ddkr:|S|dd�}d}t|�}g}xHd|ko||knr�tj||�}tj||�}|r�|r�|j||d��Pnd	}}|r�|jd�}n|r|jd�}n|rZ|s!||krZ|j|||��|j||d�|d}qe|j|||��|jtt||d|d�d���|d}qeWt|�S)
N�rr.������r�r�)	�len�
_OctalPatt�search�
_QuotePatt�append�start�chr�intr�)r��i�n�resZo_matchZq_match�j�kr
r
r�_unquote�s6 

.r�ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc	Csoddlm}m}|�}|||�\	}}}}	}
}}}
}d|||||||	|
|fS)Nr)�gmtime�timez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r�r�)ZfutureZweekdaynameZ	monthnamer�r�ZnowZyearZmonthZdayZhhZmmZssZwd�y�zr
r
r�_getdate)s
	+r�c@s�eZdZdZidd6dd6dd6dd6d	d
6dd6d
d6dd6ZddhZdd�Zdd�Zdd�Ze	dd�Z
dddd�ZeZdd�Z
ddd �Zdd!d"�ZdS)#�Morsela�A class to hold ONE (key, value) pair.

    In a cookie, each such pair may have several attributes, so this class is
    used to keep the attributes associated with the appropriate key,value pair.
    This class also includes a coded_value attribute, which is used to hold
    the network representation of the value.  This is most useful when Python
    objects are pickled for network transit.
    �expiresZPath�path�CommentZcommentZDomainZdomainzMax-Agezmax-ageZSecure�secureZHttpOnly�httponlyZVersion�versioncCsBd|_|_|_x$|jD]}tj||d�q!WdS)Nr)�key�value�coded_value�	_reserved�dict�__setitem__)�selfr�r
r
r�__init__TszMorsel.__init__cCsE|j�}||jkr.td|��ntj|||�dS)NzInvalid Attribute %s)�lowerr�rr�r�)r��K�Vr
r
rr�\szMorsel.__setitem__cCs|j�|jkS)N)r�r�)r�r�r
r
r�
isReservedKeybszMorsel.isReservedKeycsy|j�|jkr(td|��nt�fdd�|D��rZtd|��n||_||_||_dS)Nz!Attempt to set a reserved key: %sc3s|]}|�kVqdS)Nr
)r�r�)r�r
rr�jszMorsel.set.<locals>.<genexpr>zIllegal key value: %s)r�r�r�anyr�r�r�)r�r��valZ	coded_valr�r
)r�r�setes		z
Morsel.setNzSet-Cookie:cCsd||j|�fS)Nz%s %s)�OutputString)r��attrs�headerr
r
r�outputrsz
Morsel.outputcCs#d|jj|jt|j�fS)Nz<%s: %s=%s>)�	__class__rr��reprr�)r�r
r
r�__repr__wszMorsel.__repr__cCsd|j|�jdd�S)Nz�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        r.z\")r��replace)r�r�r
r
r�	js_output{szMorsel.js_outputcCswg}|j}|d|j|jf�|dkrA|j}nt|j��}x|D]\}}|dkrxqZn||kr�qZn|dkr�t|t�r�|d|j|t|�f�qZ|dkrt|t�r|d|j||f�qZ|dkr(|t	|j|��qZ|dkrN|t	|j|��qZ|d|j||f�qZWt
|�S)Nz%s=%srr�zmax-agez%s=%dr�r�)r�r�r�r��sorted�items�
isinstancer�r�r��_semispacejoin)r�r��resultr�r�r�r�r
r
rr��s*	$zMorsel.OutputString)rrr	�__doc__r��_flagsr�r�r��_LegalCharsr�r��__str__r�r�r�r
r
r
rr�1s(


r�z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z�
    (?x)                           # This is a verbose pattern
    \s*                            # Optional whitespace at start of cookie
    (?P<key>                       # Start of group 'key'
    [a	]+?   # Any word of at least one letter
    )                              # End of group 'key'
    (                              # Optional group: there may not be a value.
    \s*=\s*                          # Equal Sign
    (?P<val>                         # Start of group 'val'
    "(?:[^\\"]|\\.)*"                  # Any doublequoted string
    |                                  # or
    \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT  # Special case for "expires" attr
    |                                  # or
    [a-]*      # Any word or empty string
    )                                # End of group 'val'
    )?                             # End of optional value group
    \s*                            # Any number of spaces.
    (\s+|;|$)                      # Ending either at space, semicolon, or EOS.
    c@s�eZdZdZdd�Zdd�Zddd�Zd	d
�Zdd�Zdd
ddd�Z	e	Z
dd�Zddd�Zdd�Z
edd�ZdS)rz'A container class for a set of Morsels.cCs
||fS)a
real_value, coded_value = value_decode(STRING)
        Called prior to setting a cookie's value from the network
        representation.  The VALUE is the value read from HTTP
        header.
        Override this function to modify the behavior of cookies.
        r
)r�r�r
r
r�value_decode�szBaseCookie.value_decodecCst|�}||fS)z�real_value, coded_value = value_encode(VALUE)
        Called prior to setting a cookie's value from the dictionary
        representation.  The VALUE is the value being assigned.
        Override this function to modify the behavior of cookies.
        )r�)r�r��strvalr
r
r�value_encode�szBaseCookie.value_encodeNcCs|r|j|�ndS)N)�load)r��inputr
r
rr��szBaseCookie.__init__cCs?|j|t��}|j|||�tj|||�dS)z+Private method for setting a cookie's valueN)r�r�r�r�r�)r�r�Z
real_valuer��Mr
r
rZ__set�szBaseCookie.__setcCsQt|t�r%tj|||�n(|j|�\}}|j|||�dS)zDictionary style assignment.N)r�r�r�r�r��_BaseCookie__set)r�r�r��rval�cvalr
r
rr��szBaseCookie.__setitem__zSet-Cookie:z
cCsUg}t|j��}x-|D]%\}}|j|j||��qW|j|�S)z"Return a string suitable for HTTP.)r�r�r�r��join)r�r�r��sepr�r�r�r�r
r
rr��s
zBaseCookie.outputcCsig}t|j��}x4|D],\}}|jd|t|j�f�qWd|jjt|�fS)Nz%s=%sz<%s: %s>)r�r�r�r�r�r�r�
_spacejoin)r��lr�r�r�r
r
rr��s
$zBaseCookie.__repr__cCsOg}t|j��}x*|D]"\}}|j|j|��qWt|�S)z(Return a string suitable for JavaScript.)r�r�r�r�r�)r�r�r�r�r�r�r
r
rr�s
zBaseCookie.js_outputcCsJt|t�r|j|�n'x$|j�D]\}}|||<q,WdS)z�Load cookies from a string (presumably HTTP_COOKIE) or
        from a dictionary.  Loading cookies from a dictionary 'd'
        is equivalent to calling:
            map(Cookie.__setitem__, d.keys(), d.values())
        N)r�r��_BaseCookie__parse_stringr�)r�Zrawdatar�r�r
r
rr�
s
zBaseCookie.loadcCs\d}t|�}d}x=d|ko2|knrW|j||�}|sSPn|jd�|jd�}}|jd�}|ddkr�|rT|||dd�<qTq|j�tjkr|rT|dkr�|j�tjkr
d||<q
qt|�||<qTq|dk	r|j	|�\}	}
|j
||	|
�||}qqWdS)Nrr�r��$r�T)r��match�group�endr�r�r�r�r�r�r)r�r�Zpattr�r�rrr�r�rrr
r
rZ__parse_strings,zBaseCookie.__parse_string)rrr	r�r�r�r�rr�r�r�r�r�r��_CookiePatternr	r
r
r
rr�s			c@s.eZdZdZdd�Zdd�ZdS)rz�
    SimpleCookie supports strings as cookie values.  When setting
    the value using the dictionary assignment notation, SimpleCookie
    calls the builtin str() to convert the value to a string.  Values
    received from HTTP are kept as strings.
    cCst|�|fS)N)r�)r�r�r
r
rr�BszSimpleCookie.value_decodecCst|�}|t|�fS)N)r�r�)r�r�r�r
r
rr�EszSimpleCookie.value_encodeN)rrr	r�r�r�r
r
r
rr;s)r��re�string�__all__rr�r�r�	ExceptionrZ
ascii_lettersZdigitsr�r�r��compiler�r�r�Z_weekdaynameZ
_monthnamer�r�r�Z_LegalKeyCharsZ_LegalValueChars�ASCIIrrrr
r
r
r�<module>s�			
2~

r

?>