AlkantarClanX12

Your IP : 3.15.12.95


Current Path : /proc/self/root/opt/alt/python39/lib64/python3.9/http/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python39/lib64/python3.9/http/__pycache__/cookies.cpython-39.pyc

a

R�f�M�@sZdZddlZddlZddlZgd�ZdjZdjZdjZGdd�de	�Z
ejejd	Z
e
d
Zdd�eed
��eeee��D�Ze�ed�ded�di�e�de�e
��jZdd�Ze�d�jZdd�Zdd�Zgd�Zgd�Zdeefdd�Z Gdd�de!�Z"d Z#e#d!Z$e�d"e#d#e$d$ej%ej&B�Z'Gd%d&�d&e!�Z(Gd'd(�d(e(�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=\\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@seZdZdS)rN)�__name__�
__module__�__qualname__�r
r
�1/opt/alt/python39/lib64/python3.9/http/cookies.pyr�srz!#$%&'*+-.^_`|~:z
 ()/<=>?@[]{}cCsi|]}|d|�qS)z\%03or
)�.0�nr
r
r�
<dictcomp>�s�r��"�\"�\z\\z[%s]+cCs*|dust|�r|Sd|�t�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��strr
r
r�_quote�srz\\(?:([0-3][0-7][0-7])|(.))cCs&|drtt|dd��S|dSdS)N���)�chr�int)�mr
r
r�_unquote_replace�srcCsJ|dust|�dkr|S|ddks0|ddkr4|S|dd�}tt|�S)Nrrr���r)�len�_unquote_subrrr
r
r�_unquote�sr#)ZMonZTueZWedZThuZFriZSatZSun)
NZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc	CsRddlm}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�eZdZdZdddddddd	d
d�	Zdd
hZdd�Zedd��Zedd��Z	edd��Z
dd�Zd2dd�Zdd�Z
ejZdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd3d*d+�ZeZd,d-�Zd4d.d/�Zd5d0d1�Zeej�ZdS)6�MorselaCA 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.
    �expires�Path�CommentZDomainzMax-AgeZSecureZHttpOnlyZVersionZSameSite)	r*�path�commentZdomain�max-age�secure�httponly�versionZsamesiter0r1cCs0d|_|_|_|jD]}t�||d�qdS)Nr)�_key�_value�_coded_value�	_reserved�dict�__setitem__)�self�keyr
r
r�__init__s
zMorsel.__init__cCs|jS�N)r3�r9r
r
rr:sz
Morsel.keycCs|jSr<)r4r=r
r
r�valueszMorsel.valuecCs|jSr<)r5r=r
r
r�coded_valueszMorsel.coded_valuecCs2|��}||jvr td|f��t�|||�dS�NzInvalid attribute %r)�lowerr6rr7r8)r9�K�Vr
r
rr8#s
zMorsel.__setitem__NcCs.|��}||jvr td|f��t�|||�Sr@)rAr6rr7�
setdefault)r9r:�valr
r
rrD)s
zMorsel.setdefaultcCs>t|t�stSt�||�o<|j|jko<|j|jko<|j|jkSr<)�
isinstancer)�NotImplementedr7�__eq__r4r3r5�r9Zmorselr
r
rrH/s

�
�
�z
Morsel.__eq__cCs$t�}t�||�|j�|j�|Sr<)r)r7�update�__dict__rIr
r
r�copy9szMorsel.copycCsRi}t|���D]0\}}|��}||jvr8td|f��|||<qt�||�dSr@)r7�itemsrAr6rrJ)r9�values�datar:rEr
r
rrJ?s

z
Morsel.updatecCs|��|jvSr<)rAr6)r9rBr
r
r�
isReservedKeyHszMorsel.isReservedKeycCsH|��|jvrtd|f��t|�s2td|f��||_||_||_dS)Nz Attempt to set a reserved key %rzIllegal key %r)rAr6rrr3r4r5)r9r:rEZ	coded_valr
r
r�setKsz
Morsel.setcCs|j|j|jd�S)N)r:r>r?�r3r4r5r=r
r
r�__getstate__Vs�zMorsel.__getstate__cCs"|d|_|d|_|d|_dS)Nr:r>r?rR)r9�stater
r
r�__setstate__]s

zMorsel.__setstate__�Set-Cookie:cCsd||�|�fS)Nz%s %s)�OutputString)r9�attrs�headerr
r
r�outputbsz
Morsel.outputcCsd|jj|��fS)N�<%s: %s>)�	__class__rrWr=r
r
r�__repr__gszMorsel.__repr__cCsd|�|��dd�S)Nz�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        rr)rW�replace)r9rXr
r
r�	js_outputjs�zMorsel.js_outputcCs$g}|j}|d|j|jf�|dur,|j}t|���}|D]�\}}|dkrNq<||vrXq<|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<||jv�r|�r|t	|j|��q<|d|j||f�q<t|�S)N�%s=%srr*r/z%s=%dr.)
�appendr:r?r6�sortedrMrFrr(rr�_flags�_semispacejoin)r9rX�resultrarMr:r>r
r
rrWts,zMorsel.OutputString)N)NrV)N)N)rrr	�__doc__r6rcr;�propertyr:r>r?r8rDrH�object�__ne__rLrJrPrQrSrUrZ�__str__r]r_rW�classmethod�types�GenericAlias�__class_getitem__r
r
r
rr)�sF�



	



!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
�r9rEr
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�r9rEZstrvalr
r
r�value_encode�szBaseCookie.value_encodeNcCs|r|�|�dSr<)�load)r9�inputr
r
rr;�szBaseCookie.__init__cCs.|�|t��}|�|||�t�|||�dS)z+Private method for setting a cookie's valueN)�getr)rQr7r8)r9r:Z
real_valuer?�Mr
r
rZ__set�szBaseCookie.__setcCs:t|t�rt�|||�n|�|�\}}|�|||�dS)zDictionary style assignment.N)rFr)r7r8rr�_BaseCookie__set)r9r:r>�rval�cvalr
r
rr8�s
zBaseCookie.__setitem__rV�
cCs:g}t|���}|D]\}}|�|�||��q|�|�S)z"Return a string suitable for HTTP.)rbrMrarZ�join)r9rXrY�seprerMr:r>r
r
rrZ�s
zBaseCookie.outputcCsJg}t|���}|D] \}}|�d|t|j�f�qd|jjt|�fS)Nr`r[)rbrMra�reprr>r\r�
_spacejoin)r9�lrMr:r>r
r
rr]�s
zBaseCookie.__repr__cCs6g}t|���}|D]\}}|�|�|��qt|�S)z(Return a string suitable for JavaScript.)rbrMrar_�	_nulljoin)r9rXrerMr:r>r
r
rr_�s
zBaseCookie.js_outputcCs4t|t�r|�|�n|��D]\}}|||<qdS)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)rFr�_BaseCookie__parse_stringrM)r9Zrawdatar:r>r
r
rrs�s


zBaseCookie.loadcCs�d}t|�}g}d}d}d}d|kr2|k�rnn�|�||�}	|	sJ�q|	�d�|	�d�}
}|	�d�}|
ddkr�|s|q|�||
dd�|f�q|
��tjvr�|s�dS|dur�|
��tjvr�|�||
df�q�dSn|�||
t	|�f�q|du�r|�||
|�
|�f�d}qdSqd}|D]Z\}
}
}|
|k�rP|du�sFJ�|||
<n,|
|k�s^J�|\}}|�|
||�||
}�q$dS)	NrFrrr:rE�$T)r!�match�group�endrarAr)r6rcr#rprw)r9rZpatt�ir
Zparsed_itemsZmorsel_seenZTYPE_ATTRIBUTEZ
TYPE_KEYVALUEr�r:r>rv�tprxryr
r
rZ__parse_string	sJ



zBaseCookie.__parse_string)N)NrVrz)N)rrr	rfrprrr;rwr8rZrjr]r_rs�_CookiePatternr�r
r
r
rr�s		
	

rc@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|�|fSr<)r#ror
r
rrpMszSimpleCookie.value_decodecCst|�}|t|�fSr<)rrrqr
r
rrrPszSimpleCookie.value_encodeN)rrr	rfrprrr
r
r
rrFsr)*rf�re�stringrl�__all__r{r�rdr~�	ExceptionrZ
ascii_lettersZdigitsZ_LegalCharsZ_UnescapedCharsrQ�range�map�ordrrJ�compile�escape�	fullmatchrr�subr"rr#Z_weekdaynameZ
_monthnamer(r7r)Z_LegalKeyCharsZ_LegalValueChars�ASCII�VERBOSEr�rrr
r
r
r�<module>'sV]��
6����
�