%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core18/current/usr/lib/python3.6/http/__pycache__/
Upload File :
Create Path :
Current File : //snap/core18/current/usr/lib/python3.6/http/__pycache__/cookies.cpython-36.pyc

3

���iW�
@s�dZddlZddlZdddgZdjZdjZdjZd	d
�ZGdd�de	�Z
ejejdZ
e
d
Zdd�eed��eeee��D�Zejed�ded�di�ejdeje
��jZejd�Zdd�Zdd�Zejd�Zejd�Zdd�Zdd d!d"d#d$d%gZdd&d'd(d)d*d+d,d-d.d/d0d1g
Z dee fd2d3�Z!Gd4d5�d5e"�Z#d6Z$e$d7Z%ejd8e$d9e%d:ej&ej'B�Z(Gd;d�de"�Z)Gd<d�de)�Z*dS)=a%

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=;";')
   >>> print(C)
   Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=;"

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; � cCs$ddl}d|}|j|tdd�dS)NrzvThe .%s setter is deprecated. The attribute will be read-only in future releases. Please use the set() method instead.�)�
stacklevel)�warnings�warn�DeprecationWarning)�setterr	�msg�r�"/usr/lib/python3.6/http/cookies.py�_warn_deprecated_setter�src@seZdZdS)rN)�__name__�
__module__�__qualname__rrrrr�sz!#$%&'*+-.^_`|~:z
 ()/<=>?@[]{}cCsi|]}d||�qS)z\%03or)�.0�nrrr�
<dictcomp>�sr��"z\"�\z\\z[%s]+z[\x00-\x1F\x7F]cGstdd�|D��S)zhDetects control characters within a value.
    Supports any type, as header values can be any type.
    css|]}tjt|��VqdS)N)�_control_character_re�search�str)r�vrrr�	<genexpr>�sz)_has_control_character.<locals>.<genexpr>)�any)�valrrr�_has_control_character�sr!cCs*|dkst|�r|Sd|jt�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.
    Nr)�
_is_legal_key�	translate�_Translator)rrrr�_quote�sr%z\\[0-3][0-7][0-7]z[\\].cCsT|dkst|�dkr|S|ddks0|ddkr4|S|dd�}d}t|�}g}x�d|kod|kn�rJtj||�}tj||�}|r�|r�|j||d��Pd	}}|r�|jd�}|r�|jd�}|o�|s�||k�r
|j|||��|j||d�|d}qR|j|||��|jtt||d|d�d���|d}qRWt|�S)
N�rr������r*r*)	�len�
_OctalPattr�
_QuotePatt�append�start�chr�int�	_nulljoin)r�irZresZo_matchZq_match�j�krrr�_unquote�s6


$r6ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc	CsRddlm}m}|�}|||�\	}}}}	}
}}}
}d|||||||	|
|fS)Nr)�gmtime�timez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r8r7)ZfutureZweekdaynameZ	monthnamer7r8ZnowZyearZmonthZdayZhhZmmZssZwd�y�zrrr�_getdates
r;c	@seZdZdZdddddddd	d
�ZddhZd
d�Zedd��Zej	dd��Zedd��Z
e
j	dd��Z
edd��Zej	dd��Zdd�Zd4dd�Z
dd�ZejZdd �Zd!d"�Zd#d$�Zefd%d&�Zd'd(�Zd)d*�Zd5d,d-�ZeZd.d/�Zd6d0d1�Zd7d2d3�ZdS)8�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�CommentZDomainzMax-AgeZSecureZHttpOnlyZVersion)r=�path�commentZdomainzmax-age�secure�httponly�versionrArBcCs4d|_|_|_x|jD]}tj||d�qWdS)Nr)�_key�_value�_coded_value�	_reserved�dict�__setitem__)�self�keyrrr�__init__/szMorsel.__init__cCs|jS)N)rD)rJrrrrK7sz
Morsel.keycCstd�||_dS)NrK)rrD)rJrKrrrrK;scCs|jS)N)rE)rJrrr�value@szMorsel.valuecCstd�||_dS)NrM)rrE)rJrMrrrrMDscCs|jS)N)rF)rJrrr�coded_valueIszMorsel.coded_valuecCstd�||_dS)NrN)rrF)rJrNrrrrNMscCsP|j�}||jkr td|f��t||�r>td|�d|����tj|||�dS)NzInvalid attribute %rz.Control characters are not allowed in cookies r)�lowerrGrr!rHrI)rJ�K�VrrrrIRs

zMorsel.__setitem__NcCsH|j�}||jkr td|f��t||�r:td||f��tj|||�S)NzInvalid attribute %rz3Control characters are not allowed in cookies %r %r)rOrGrr!rH�
setdefault)rJrKr rrrrRZs

zMorsel.setdefaultcCs>t|t�stStj||�o<|j|jko<|j|jko<|j|jkS)N)�
isinstancer<�NotImplementedrH�__eq__rErDrF)rJ�morselrrrrUbs
z
Morsel.__eq__cCs$t�}tj||�|jj|j�|S)N)r<rH�update�__dict__)rJrVrrr�copylszMorsel.copycCsVi}x@t|�j�D]0\}}|j�}||jkr:td|f��|||<qWtj||�dS)NzInvalid attribute %r)rH�itemsrOrGrrW)rJ�values�datarKr rrrrWrs
z
Morsel.updatecCs|j�|jkS)N)rOrG)rJrPrrr�
isReservedKey{szMorsel.isReservedKeycCs�|tkr ddl}|jdtdd�|j�|jkr<td|f��t|�sRtd|f��t|||�rptd|||f��||_	||_
||_dS)NrzSLegalChars parameter is deprecated, ignored and will be removed in future versions.r&)rz Attempt to set a reserved key %rzIllegal key %rz6Control characters are not allowed in cookies %r %r %r)�_LegalCharsr	r
rrOrGrr"r!rDrErF)rJrKr Z	coded_valZ
LegalCharsr	rrr�set~s z
Morsel.setcCs|j|j|jd�S)N)rKrMrN)rDrErF)rJrrr�__getstate__�szMorsel.__getstate__cCs"|d|_|d|_|d|_dS)NrKrMrN)rDrErF)rJ�staterrr�__setstate__�s

zMorsel.__setstate__�Set-Cookie:cCsd||j|�fS)Nz%s %s)�OutputString)rJ�attrs�headerrrr�output�sz
Morsel.outputcCsd|jj|j�fS)Nz<%s: %s>)�	__class__rrd)rJrrr�__repr__�szMorsel.__repr__cCsd|j|�jdd�S)Nz�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        rz\")rd�replace)rJrerrr�	js_output�szMorsel.js_outputcCs(g}|j}|d|j|jf�|dkr,|j}t|j��}x�|D]�\}}|dkrPq>||krZq>|dkr�t|t�r�|d|j|t|�f�q>|dkr�t|t�r�|d|j||f�q>|dkr�t|t	�r�|d|j|t
|�f�q>||jk�r|�r|t	|j|��q>|d|j||f�q>Wt|�S)Nz%s=%srr=zmax-agez%s=%dr@)
r.rKrNrG�sortedrZrSr1r;rr%�_flags�_semispacejoin)rJre�resultr.rZrKrMrrrrd�s,zMorsel.OutputString)N)Nrc)N)N)rrr�__doc__rGrmrL�propertyrKrrMrNrIrRrU�object�__ne__rYrWr]r^r_r`rbrg�__str__rirkrdrrrrr<s@
	


r<z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z�
    \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@sneZdZdZdd�Zdd�Zddd�Zd	d
�Zdd�Zddd�Z	e	Z
dd�Zddd�Zdd�Z
efdd�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)rJr rrr�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)rJr �strvalrrr�value_encodeszBaseCookie.value_encodeNcCs|r|j|�dS)N)�load)rJ�inputrrrrL
szBaseCookie.__init__cCs.|j|t��}|j|||�tj|||�dS)z+Private method for setting a cookie's valueN)�getr<r_rHrI)rJrKZ
real_valuerN�MrrrZ__setszBaseCookie.__setcCs:t|t�rtj|||�n|j|�\}}|j|||�dS)zDictionary style assignment.N)rSr<rHrIrw�_BaseCookie__set)rJrKrM�rval�cvalrrrrIs
zBaseCookie.__setitem__�Set-Cookie:�
c	CsRg}t|j��}x6|D].\}}|j||�}t|�r:td��|j|�qW|j|�S)z"Return a string suitable for HTTP.z-Control characters are not allowed in cookies)rlrZrgr!rr.�join)	rJrerf�seprorZrKrMZvalue_outputrrrrgszBaseCookie.outputcCsNg}t|j��}x(|D] \}}|jd|t|j�f�qWd|jjt|�fS)Nz%s=%sz<%s: %s>)rlrZr.�reprrMrhr�
_spacejoin)rJ�lrZrKrMrrrri*s
zBaseCookie.__repr__cCs:g}t|j��}x |D]\}}|j|j|��qWt|�S)z(Return a string suitable for JavaScript.)rlrZr.rkr2)rJrerorZrKrMrrrrk1s
zBaseCookie.js_outputcCs8t|t�r|j|�nx|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)rSr�_BaseCookie__parse_stringrZ)rJZrawdatarKrMrrrrx9s

zBaseCookie.loadcCs�d}t|�}g}d}d}d}�xd|ko2|kn�r|j||�}	|	sLP|	jd�|	jd�}
}|	jd�}|
ddkr�|s~q |j||
dd�|f�q |
j�tjkr�|s�dS|dkr�|
j�tjkr�|j||
df�q�dSn|j||
t	|�f�q |dk	�r|j||
|j
|�f�d}q dSq Wd}xb|D]Z\}
}
}|
|k�rV|dk	�sLt�|||
<n,|
|k�sdt�|\}}|j|
||�||
}�q*WdS)	NrFr'r&rKr �$T)
r+�match�group�endr.rOr<rGrmr6ru�AssertionErrorr|)rJrZpattr3rZparsed_itemsZmorsel_seenZTYPE_ATTRIBUTEZ
TYPE_KEYVALUEr�rKrMr{�tpr}r~rrrZ__parse_stringGsJ



zBaseCookie.__parse_string)N)Nrr�)N)rrrrprurwrLr|rIrgrtrirkrx�_CookiePatternr�rrrrr�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.
    cCst|�|fS)N)r6)rJr rrrru�szSimpleCookie.value_decodecCst|�}|t|�fS)N)rr%)rJr rvrrrrw�szSimpleCookie.value_encodeN)rrrrprurwrrrrr�s)+rp�re�string�__all__r�r2rnr�r�	ExceptionrZ
ascii_lettersZdigitsr^Z_UnescapedCharsr_�range�map�ordr$rW�compile�escape�	fullmatchr"rr!r%r,r-r6Z_weekdaynameZ
_monthnamer;rHr<Z_LegalKeyCharsZ_LegalValueChars�ASCII�VERBOSEr�rrrrrr�<module>sJ
	


2Q

Zerion Mini Shell 1.0