
    Ph|^                        d Z ddlZddlZg dZdj                  Zdj                  Zdj                  Zd Z G d d	e	      Z
ej                  ej                  z   d
z   Zedz   Z e ed             e eee            z
  D  ci c]  } | d| z  
 c} Zej)                   ed      d ed      di        ej*                  d ej,                  e      z        j.                  Zd Z ej*                  d      Z ej*                  d      Zd Zg dZg dZdeefdZ G d de       Z!dZ"e"dz   Z# ej*                  de"z   dz   e#z   d z   ejH                        Z% G d! d"e       Z& G d# d$e&      Z'yc c} w )%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                 F    dd l }d| z  }|j                  |t        d       y )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   msgs      fC:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\eventlet/green/http/cookies.py_warn_deprecated_setterr      s)    CEKLCMM#)aM8    c                       e Zd Zy)r   N)__name__
__module____qualname__ r   r   r   r      s    r   r   z!#$%&'*+-.^_`|~:z ()/<=>?@[]{}   z\%03o"\"\z\\z[%s]+\Zc                 V    | t        |       r| S d| j                  t              z   dz   S )zQuote 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.
    r   )_is_legal_key	translate_Translatorstrs    r   _quoter#      s.     {mC(
S]];//#55r   z\\[0-3][0-7][0-7]z[\\].c           
         | t        |       dk  r| S | d   dk7  s| d   dk7  r| S | dd } d}t        |       }g }d|cxk  r|k  r n t        |      S t        j                  | |      }t        j                  | |      }|s"|s |j	                  | |d         	 t        |      S dx}}|r|j                  d      }|r|j                  d      }|r8|r||k  r1|j	                  | ||        |j	                  | |dz             |dz   }nF|j	                  | ||        |j	                  t        t        | |dz   |dz    d                   |dz   }d|cxk  r|k  rt        |      S  t        |      S )N   r   r            )	len
_OctalPattsearch
_QuotePattappendstartchrint	_nulljoin)r"   inreso_matchq_matchjks           r   _unquoter:      s    {c#hl

1v}B3
 a)C 	
ACA
C
q*1*( S>' ##C+##C+wJJs12w S> 
Aa Aa AGq1uJJs1Qx JJs1Q3x AAJJs1Qx JJs3s1Q3qs|Q/01AA' q*1*( S>) ( S>r   )MonTueWedThuFriSatSun)NJanFebMarAprMayJunJulAugSepOctNovDecc           	      n    ddl m}m}  |       } ||| z         \	  }}}}	}
}}}}d||   |||   ||	|
|fz  S )Nr   )gmtimetimez#%s, %02d %3s %4d %02d:%02d:%02d GMT)eventlet.green.timerO   rP   )futureweekdayname	monthnamerO   rP   nowyearmonthdayhhmmsswdyzs                  r   _getdater_   2  sW    0
&C-3C&L-A*D%b"b"a0OS)E"2D"b"EF Fr   c            	       F   e Zd ZdZdddddddd	d
ZddhZd Zed        Zej                  d        Zed        Z
e
j                  d        Z
ed        Zej                  d        Zd Zd"dZd Zej                   Zd Zd Zd ZefdZd Zd Zd#dZeZd Zd"d Zd"d!Zy)$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)rb   pathcommentdomainmax-agesecurehttponlyversionrm   rn   c                 ~    d x| _         x| _        | _        | j                  D ]  }t        j                  | |d        y )Nr   )_key_value_coded_value	_reserveddict__setitem__selfkeys     r   __init__zMorsel.__init__]  s:    6::	:DK$"3 >>CT3+ "r   c                     | j                   S N)rq   rx   s    r   ry   z
Morsel.keye  s    yyr   c                 (    t        d       || _        y )Nry   )r   rq   rw   s     r   ry   z
Morsel.keyi  s    &	r   c                     | j                   S r|   )rr   r}   s    r   valuezMorsel.valuen  s    {{r   c                 (    t        d       || _        y )Nr   )r   rr   )rx   r   s     r   r   zMorsel.valuer  s    (r   c                     | j                   S r|   )rs   r}   s    r   coded_valuezMorsel.coded_valuew  s       r   c                 (    t        d       || _        y )Nr   )r   rs   )rx   r   s     r   r   zMorsel.coded_value{  s    .'r   c                     |j                         }|| j                  vrt        d|      t        j	                  | ||       y NzInvalid attribute )lowerrt   r   ru   rv   )rx   KVs      r   rv   zMorsel.__setitem__  s9    GGIDNN";<<q!$r   Nc                     |j                         }|| j                  vrt        d|      t        j	                  | ||      S r   )r   rt   r   ru   
setdefault)rx   ry   vals      r   r   zMorsel.setdefault  s:    iikdnn$=>>tS#..r   c                     t        |t              st        S t        j	                  | |      xrO | j
                  |j
                  k(  xr4 | j                  |j                  k(  xr | j                  |j                  k(  S r|   )
isinstancera   NotImplementedru   __eq__rr   rq   rs   rx   morsels     r   r   zMorsel.__eq__  sj    &&)!!D&) 9v}},9		V[[(9 !!V%8%88	:r   c                     t               }t        j                  ||        |j                  j                  | j                         |S r|   )ra   ru   update__dict__r   s     r   copyzMorsel.copy  s2    FD!t}}-r   c                     i }t        |      j                         D ]6  \  }}|j                         }|| j                  vrt	        d|      |||<   8 t         j                  | |       y r   )ru   itemsr   rt   r   r   )rx   valuesdatary   r   s        r   r   zMorsel.update  s`    V**,HC))+C$..(!C"ABBDI	 -
 	D$r   c                 :    |j                         | j                  v S r|   )r   rt   )rx   r   s     r   isReservedKeyzMorsel.isReservedKey  s    wwyDNN**r   c                     |t         k7  rdd l}|j                  dt        d       |j	                         | j
                  v rt        d|      t        |      st        d|      || _        || _	        || _
        y )Nr   zSLegalChars parameter is deprecated, ignored and will be removed in future versions.r%   r
   zAttempt to set a reserved key zIllegal key )_LegalCharsr   r   r   r   rt   r   r   rq   rr   rs   )rx   ry   r   	coded_val
LegalCharsr   s         r   setz
Morsel.set  sy    $MM12D  
 99;$..(CIJJS!#788 	%r   c                 J    | j                   | j                  | j                  dS )N)ry   r   r   rq   rr   rs   r}   s    r   __getstate__zMorsel.__getstate__  s#    99[[,,
 	
r   c                 @    |d   | _         |d   | _        |d   | _        y )Nry   r   r   r   )rx   states     r   __setstate__zMorsel.__setstate__  s%    %L	Gn!-0r   c                 .    |d| j                  |      S )Nr   )OutputString)rx   attrsheaders      r   outputzMorsel.output  s     $"3"3E":;;r   c                 X    d| j                   j                  d| j                         dS )N<: >)	__class__r   r   r}   s    r   __repr__zMorsel.__repr__  s     !^^44d6G6G6IJJr   c                 J    d| j                  |      j                  dd      z  S )Nz
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        r   r   )r   replace)rx   r   s     r   	js_outputzMorsel.js_output  s.       '//U;= 	=r   c                 T   g }|j                   } || j                  d| j                         || j                  }t	        | j                               }|D ]  \  }}|dk(  r||vr|dk(  r4t        |t              r$ || j                  |   dt        |             J|dk(  r+t        |t              r |d| j                  |   |fz         z|| j                  v r"|s |t        | j                  |                 || j                  |   d|        t        |      S )N=r   rb   rl   z%s=%d)r.   ry   r   rt   sortedr   r   r1   r_   _flagsr"   _semispacejoin)rx   r   resultr.   r   ry   r   s          r   r   zMorsel.OutputString  s     	$((D$4$456 =NNEtzz|$JC{%iJuc$:$.."5xGH	!j&<w$.."5u!==>#3t~~c234$.."5u=>    f%%r   r|   )NSet-Cookie:)r   r   r   __doc__rt   r   rz   propertyry   r   r   r   rv   r   r   object__ne__r   r   r   r   r   r   r   r   __str__r   r   r   r   r   r   ra   ra   :  s   , 	I 
#F,   	ZZ    \\  ! ! ( (%/: ]]F + 3> &$
1
< GK=&r   ra   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                   Z    e Zd ZdZd Zd ZddZd Zd ZddZ	e	Z
d	 Zdd
Zd ZefdZy)r   z'A container class for a set of Morsels.c                 
    ||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   rx   r   s     r   value_decodezBaseCookie.value_decode  s     Cxr   c                      t        |      }||fS )zreal_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!   rx   r   strvals      r   value_encodezBaseCookie.value_encode'  s     Sv~r   Nc                 ,    |r| j                  |       y y r|   )load)rx   inputs     r   rz   zBaseCookie.__init__0  s    IIe r   c                     | j                  |t                     }|j                  |||       t        j	                  | ||       y)z+Private method for setting a cookie's valueN)getra   r   ru   rv   )rx   ry   
real_valuer   Ms        r   __setzBaseCookie.__set4  s6    HHS&(#	c:{+sA&r   c                     t        |t              rt        j                  | ||       y| j	                  |      \  }}| j                  |||       y)zDictionary style assignment.N)r   ra   ru   rv   r   _BaseCookie__set)rx   ry   r   rvalcvals        r   rv   zBaseCookie.__setitem__:  sB    eV$T3.**51JD$JJsD$'r   c                     g }t        | j                               }|D ]&  \  }}|j                  |j                  ||             ( |j	                  |      S )z"Return a string suitable for HTTP.)r   r   r.   r   join)rx   r   r   sepr   r   ry   r   s           r   r   zBaseCookie.outputC  sK    tzz|$JCMM%,,uf56  xxr   c                     g }t        | j                               }|D ].  \  }}|j                  |dt        |j                               0 d| j
                  j                  dt        |      dS )Nr   r   r   r   )r   r   r.   reprr   r   r   
_spacejoin)rx   lr   ry   r   s        r   r   zBaseCookie.__repr__M  sX    tzz|$JCHHT%++%678  !^^44jmDDr   c                     g }t        | j                               }|D ]%  \  }}|j                  |j                  |             ' t	        |      S )z(Return a string suitable for JavaScript.)r   r   r.   r   r2   )rx   r   r   r   ry   r   s         r   r   zBaseCookie.js_outputT  sE    tzz|$JCMM%//%01    r   c                     t        |t              r| j                  |       y|j                         D ]
  \  }}|| |<    y)zLoad 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   )rx   rawdatary   r   s       r   r   zBaseCookie.load\  sC     gs#(
 	 &mmo
U!S	 .r   c                    d}t        |      }g }d}d}d}d|cxk  r|k  r!n n|j                  ||      }	|	sn|	j                  d      |	j                  d      }}
|	j                  d      }|
d   dk(  r|sd|j	                  ||
dd  |f       n|
j                         t        j                  v rY|sy |6|
j                         t        j                  v r|j	                  ||
df       nHy |j	                  ||
t        |      f       n)|&|j	                  ||
| j                  |      f       d}ny d|cxk  r|k  rn d }|D ]9  \  }}
}||k(  r
|J |||
<   ||k(  sJ |\  }}| j                  |
||       | |
   }; y )	Nr   Fr'   r%   ry   r   $T)r*   matchgroupendr.   r   ra   rt   r   r:   r   r   )rx   r"   pattr3   r4   parsed_itemsmorsel_seenTYPE_ATTRIBUTETYPE_KEYVALUEr   ry   r   r   tpr   r   s                   r   __parse_stringzBaseCookie.__parse_stringj  s   H
 1jqjJJsA&EU+U[[-?C		!A1v}" ##^SWe$DE 0 00"=yy{fmm3$++^S$,GH  ''huo(NO"##]C9J9J59Q$RS" E 1jqjJ *NBU^#}$}#]***"
d

3d+I +r   r|   )Nr   z
)r   r   r   r   r   r   rz   r   rv   r   r   r   r   r   _CookiePatternr   r   r   r   r   r     sD    1'(  GE! (6 :r   r   c                       e Zd ZdZd Zd Zy)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                     t        |      |fS r|   )r:   r   s     r   r   zSimpleCookie.value_decode  s    }c!!r   c                 2    t        |      }|t        |      fS r|   )r"   r#   r   s      r   r   zSimpleCookie.value_encode  s    Svf~%%r   N)r   r   r   r   r   r   r   r   r   r   r     s    "&r   r   )(r   restring__all__r   r2   r   r   r   	Exceptionr   ascii_lettersdigitsr   _UnescapedCharsr   rangemapordr    r   compileescaper   r   r#   r+   r-   r:   _weekdayname
_monthnamer_   ru   ra   _LegalKeyChars_LegalValueCharsASCIIr   r   r   )r4   s   0r   <module>r     s  zXz 
 
7GG	XX
9	) 	" ""V]]25GG/ E#J#c#.G*HHJH1 (Q,HJ   HeIv  

:			+(>>?EE
6 RZZ,-
RZZ!
)d A8
 <: F{&T {&N B!F*  	 					 $ 
%0I IX&: &OJs   E-