o
    ¨Ýj}^  ã                   @   sT  d Z ddlZddlZg d¢ZdjZdjZdjZdd„ ZG d	d
„ d
e	ƒZ
ejej d Zed Zdd„ eedƒƒeeeeƒƒ D ƒZe edƒdedƒdi¡ e de e¡ ¡jZdd„ Ze d¡Ze d¡Zdd„ Zg d¢Zg d¢Zdeefdd„ZG dd „ d e ƒZ!d!Z"e"d" Z#e d#e" d$ e# d% ej$¡Z%G d&d'„ d'e ƒZ&G d(d)„ d)e&ƒZ'dS )*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                 C   s$   dd l }d|  }|j|tdd� d S )Nr   zvThe .%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   úV/var/www/html/chatgpt/venv/lib/python3.10/site-packages/eventlet/green/http/cookies.pyÚ_warn_deprecated_setterÃ   s
   ÿr   c                   @   s   e Zd ZdS )r   N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   Ì   s    r   z!#$%&'*+-.^_`|~:z ()/<=>?@[]{}c                 C   s   i | ]}|d | “qS )z\%03or   )Ú.0Únr   r   r   Ú
<dictcomp>à   s    ÿr   é   ú"ú\"ú\z\\z[%s]+\Zc                 C   s&   | du st | ƒr
| S d|  t¡ d S )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ê   s   r!   z\\[0-3][0-7][0-7]z[\\].c                 C   sn  | d u s
t | ƒdk r| S | d dks| d dkr| S | dd… } d}t | ƒ}g }d|  kr2|k r³n t|ƒS t | |¡}t | |¡}|sU|sU| | |d … ¡ 	 t|ƒS d }}|r`| d¡}|rg| d¡}|r†|ro||k r†| | ||… ¡ | | |d  ¡ |d }n| | ||… ¡ | tt| |d |d … dƒƒ¡ |d }d|  kr²|k s7t|ƒS  t|ƒS )Né   r   r   éÿÿÿÿé   é   é   )	ÚlenÚ
_OctalPattÚsearchÚ
_QuotePattÚappendÚstartÚchrÚintÚ	_nulljoin)r    Úir   ÚresZo_matchZq_matchÚjÚkr   r   r   Ú_unquoteú   s@   íó


$íìr4   )ÚMonÚTueÚWedÚThuÚFriÚSatÚSun)NÚJanÚFebÚMarÚAprÚMayÚJunÚJulÚAugÚSepÚOctÚNovÚDecc              	   C   sR   ddl m}m} |ƒ }|||  ƒ\	}}}}	}
}}}}d|| ||| ||	|
|f S )Nr   )ÚgmtimeÚtimez#%s, %02d %3s %4d %02d:%02d:%02d GMT)Zeventlet.green.timerH   rI   )ÚfutureÚweekdaynameÚ	monthnamerH   rI   ÚnowÚyearÚmonthÚdayÚhhÚmmÚssÚwdÚyÚzr   r   r   Ú_getdate2  s   ÿrW   c                	   @   s  e Zd ZdZdddddddd	d
œZddhZdd„ Zedd„ ƒZej	dd„ ƒZedd„ ƒZ
e
j	dd„ ƒZ
edd„ ƒZej	dd„ ƒZdd„ Zd4dd„Zdd„ ZejZdd „ Zd!d"„ Zd#d$„ Zefd%d&„Zd'd(„ Zd)d*„ Zd5d,d-„ZeZd.d/„ Zd4d0d1„Zd4d2d3„ZdS )6Ú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.
    ÚexpiresÚPathÚCommentÚDomainzMax-AgeÚSecureÚHttpOnlyÚVersion)rY   ÚpathÚcommentÚdomainúmax-ageÚsecureÚhttponlyÚversionrd   re   c                 C   s0   d  | _  | _| _| jD ]	}t | |d¡ qd S )Nr   )Ú_keyÚ_valueÚ_coded_valueÚ	_reservedÚdictÚ__setitem__©ÚselfÚkeyr   r   r   Ú__init__]  s   
ÿzMorsel.__init__c                 C   ó   | j S ©N)rg   ©rn   r   r   r   ro   e  ó   z
Morsel.keyc                 C   ó   t dƒ || _d S )Nro   )r   rg   rm   r   r   r   ro   i  ó   
c                 C   rq   rr   )rh   rs   r   r   r   Úvaluen  rt   zMorsel.valuec                 C   ru   )Nrw   )r   rh   )rn   rw   r   r   r   rw   r  rv   c                 C   rq   rr   )ri   rs   r   r   r   Úcoded_valuew  rt   zMorsel.coded_valuec                 C   ru   )Nrx   )r   ri   )rn   rx   r   r   r   rx   {  rv   c                 C   s2   |  ¡ }|| jvrtd|f ƒ‚t | ||¡ d S ©NzInvalid attribute %r)Úlowerrj   r   rk   rl   )rn   ÚKÚVr   r   r   rl   €  s   
zMorsel.__setitem__Nc                 C   s.   |  ¡ }|| jvrtd|f ƒ‚t | ||¡S ry   )rz   rj   r   rk   Ú
setdefault)rn   ro   Úvalr   r   r   r}   †  s   
zMorsel.setdefaultc                 C   s>   t |tƒstS t | |¡o| j|jko| j|jko| j|jkS rr   )Ú
isinstancerX   ÚNotImplementedrk   Ú__eq__rh   rg   ri   ©rn   Úmorselr   r   r   r�   Œ  s   

ÿ
þ
ýzMorsel.__eq__c                 C   s$   t ƒ }t || ¡ |j | j¡ |S rr   )rX   rk   ÚupdateÚ__dict__r‚   r   r   r   Úcopy–  s   zMorsel.copyc                 C   sR   i }t |ƒ ¡ D ]\}}| ¡ }|| jvrtd|f ƒ‚|||< qt  | |¡ d S ry   )rk   Úitemsrz   rj   r   r„   )rn   ÚvaluesÚdataro   r~   r   r   r   r„   œ  s   

zMorsel.updatec                 C   s   |  ¡ | jv S rr   )rz   rj   )rn   r{   r   r   r   ÚisReservedKey¥  s   zMorsel.isReservedKeyc                 C   sh   |t krdd l}|jdtdd� | ¡ | jv rtd|f ƒ‚t|ƒs)td|f ƒ‚|| _|| _	|| _
d S )Nr   zSLegalChars parameter is deprecated, ignored and will be removed in future versions.r"   r   z Attempt to set a reserved key %rzIllegal key %r)Ú_LegalCharsr
   r   r   rz   rj   r   r   rg   rh   ri   )rn   ro   r~   Ú	coded_valZ
LegalCharsr
   r   r   r   Úset¨  s   ý
z
Morsel.setc                 C   s   | j | j| jdœS )N)ro   rw   rx   ©rg   rh   ri   rs   r   r   r   Ú__getstate__º  s   ýzMorsel.__getstate__c                 C   s"   |d | _ |d | _|d | _d S )Nro   rw   rx   rŽ   )rn   Ústater   r   r   Ú__setstate__Á  s   

zMorsel.__setstate__úSet-Cookie:c                 C   s   d||   |¡f S )Nz%s %s)ÚOutputString)rn   ÚattrsÚheaderr   r   r   ÚoutputÆ  s   zMorsel.outputc                 C   s   d| j j|  ¡ f S )Nú<%s: %s>)Ú	__class__r   r“   rs   r   r   r   Ú__repr__Ë  s   zMorsel.__repr__c                 C   s   d|   |¡ dd¡ S )Nz—
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        r   r   )r“   Úreplace)rn   r”   r   r   r   Ú	js_outputÎ  s   úzMorsel.js_outputc                 C   sò   g }|j }|d| j| jf ƒ |d u r| j}t|  ¡ ƒ}|D ]V\}}|dkr'q||vr,q|dkrCt|tƒrC|d| j| t|ƒf ƒ q|dkrXt|tƒrX|d| j| |f ƒ q|| j	v ri|rh|t
| j| ƒƒ q|d| j| |f ƒ qt|ƒS )Nú%s=%sr   rY   rc   z%s=%d)r+   ro   rx   rj   Úsortedr‡   r   r.   rW   Ú_flagsr    Ú_semispacejoin)rn   r”   Úresultr+   r‡   ro   rw   r   r   r   r“   Ø  s*   
€zMorsel.OutputStringrr   )Nr’   )r   r   r   Ú__doc__rj   rž   rp   Úpropertyro   r   rw   rx   rl   r}   r�   ÚobjectÚ__ne__r†   r„   rŠ   r‹   r�   r�   r‘   r–   Ú__str__r™   r›   r“   r   r   r   r   rX   :  sP    ø






	


rX   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                   @   sn   e Zd ZdZdd„ Zdd„ Zddd„Zd	d
„ Zdd„ Zddd„Z	e	Z
dd„ Zddd„Zdd„ Zefdd„ZdS )r   z'A container class for a set of Morsels.c                 C   s   ||fS )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   ©rn   r~   r   r   r   Úvalue_decode  s   zBaseCookie.value_decodec                 C   s   t |ƒ}||fS )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   ©rn   r~   Ústrvalr   r   r   Úvalue_encode'  s   zBaseCookie.value_encodeNc                 C   s   |r	|   |¡ d S d S rr   )Úload)rn   Úinputr   r   r   rp   0  s   ÿzBaseCookie.__init__c                 C   s.   |   |tƒ ¡}| |||¡ t | ||¡ dS )z+Private method for setting a cookie's valueN)ÚgetrX   r�   rk   rl   )rn   ro   Ú
real_valuerx   ÚMr   r   r   Ú__set4  s   zBaseCookie.__setc                 C   s<   t |tƒrt | ||¡ dS |  |¡\}}|  |||¡ dS )zDictionary style assignment.N)r   rX   rk   rl   rª   Ú_BaseCookie__set)rn   ro   rw   ÚrvalÚcvalr   r   r   rl   :  s   
zBaseCookie.__setitem__r’   ú
c                 C   s:   g }t |  ¡ ƒ}|D ]\}}| | ||¡¡ q
| |¡S )z"Return a string suitable for HTTP.)r�   r‡   r+   r–   Újoin)rn   r”   r•   Úsepr    r‡   ro   rw   r   r   r   r–   C  s
   
zBaseCookie.outputc                 C   sJ   g }t |  ¡ ƒ}|D ]\}}| d|t|jƒf ¡ q
d| jjt|ƒf S )Nrœ   r—   )r�   r‡   r+   Úreprrw   r˜   r   Ú
_spacejoin)rn   Úlr‡   ro   rw   r   r   r   r™   M  s
   zBaseCookie.__repr__c                 C   s6   g }t |  ¡ ƒ}|D ]\}}| | |¡¡ q
t|ƒS )z(Return a string suitable for JavaScript.)r�   r‡   r+   r›   r/   )rn   r”   r    r‡   ro   rw   r   r   r   r›   T  s
   zBaseCookie.js_outputc                 C   s6   t |tƒr|  |¡ dS | ¡ D ]\}}|| |< qdS )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‡   )rn   Úrawdataro   rw   r   r   r   r«   \  s   

þ
zBaseCookie.loadc                 C   sˆ  d}t |ƒ}g }d}d}d}d|  kr|k r”n nz| ||¡}	|	s#nq|	 d¡|	 d¡}
}|	 d¡}|
d dkrI|s<q| ||
dd … |f¡ n@|
 ¡ tjv ru|sTd S |d u rj|
 ¡ tjv rh| ||
df¡ n!d S | ||
t	|ƒf¡ n|d ur‡| ||
|  
|¡f¡ d}nd S d|  kr“|k sn d }|D ])\}}
}||kr¬|d us§J ‚|||
< q˜||ks²J ‚|\}}|  |
||¡ | |
 }q˜d S )	Nr   Fr$   r"   ro   r~   ú$T)r'   ÚmatchÚgroupÚendr+   rz   rX   rj   rž   r4   r§   r±   )rn   r    Úpattr0   r   Úparsed_itemsÚmorsel_seenÚTYPE_ATTRIBUTEÚTYPE_KEYVALUEr½   ro   rw   r¯   Útpr²   r³   r   r   r   Ú__parse_stringj  sN   
Þ%

øzBaseCookie.__parse_stringrr   )Nr’   r´   )r   r   r   r¡   r§   rª   rp   r±   rl   r–   r¥   r™   r›   r«   Ú_CookiePatternrº   r   r   r   r   r     s    	
	
	
r   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )r   zþ
    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.
    c                 C   s   t |ƒ|fS rr   )r4   r¦   r   r   r   r§   ®  s   zSimpleCookie.value_decodec                 C   s   t |ƒ}|t|ƒfS rr   )r    r!   r¨   r   r   r   rª   ±  s   zSimpleCookie.value_encodeN)r   r   r   r¡   r§   rª   r   r   r   r   r   §  s    r   )(r¡   ÚreÚstringÚ__all__rµ   r/   rŸ   r¸   r   Ú	Exceptionr   Úascii_lettersÚdigitsr‹   Ú_UnescapedCharsr�   ÚrangeÚmapÚordr   r„   ÚcompileÚescaper½   r   r!   r(   r*   r4   Ú_weekdaynameÚ
_monthnamerW   rk   rX   Ú_LegalKeyCharsÚ_LegalValueCharsÚASCIIrÇ   r   r   r   r   r   r   Ú<module>   sX   \]	ÿþ

2 Hüüóóî 