;
"Ic               @   s"  d  Z  d d l Z d d l m Z m Z d d l Z d d l Z d d d g Z d j Z	 d j Z
 d	 j Z Gd
   d e  Z e j e j d Z i d 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/ 6d0 d1 6d2 d3 6d4 d5 6d6 d7 6d8 d9 6d: d; 6d< d= 6d> d? 6d@ dA 6dB dC 6dD dE 6dF dG 6dH dI 6dJ dK 6dL dM 6dN dO 6dP dQ 6dR dS 6dT dU 6dV dW 6dX dY 6dZ d[ 6d\ d] 6d^ d_ 6d` da 6db dc 6dd de 6df dg 6dh di 6dj dk 6dl dm 6dn do 6dp dq 6dr ds 6dt du 6dv dw 6dx dy 6dz 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 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/6d0d16d2d36d4d56d6d76d8d96d:d;6d<d=6d>d?6d@dA6dBdC6dDdE6dFdG6dHdI6dJdK6dLdM6dNdO6dPdQ6Z e dR Z e j dS Z e j dT Z dU  Z dVdWdXdYdZd[d\g Z d d]d^d_d`dadbdcdddedfdgdhg Z d e e di Z Gdj  dke  Z dlZ e j dme dne doe j  Z Gdp  d e  Z  Gdq  d e   Z! dr  Z" e# dsk o e"   n d S(t  u-
  
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.
i    N(   u   dumpsu   loadsu   CookieErroru
   BaseCookieu   SimpleCookieu    u   ; u    c             B   s   |  Ee  Z d  S(   N(   u   __name__u
   __module__(   u
   __locals__(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   CookieError   s   
u   !#$%&'*+-.^_`|~u   \000u    u   \001u   u   \002u   u   \003u   u   \004u   u   \005u   u   \006u   u   \007u   u   \010u   u   \011u   	u   \012u   
u   \013u   u   \014u   u   \015u   u   \016u   u   \017u   u   \020u   u   \021u   u   \022u   u   \023u   u   \024u   u   \025u   u   \026u   u   \027u   u   \030u   u   \031u   u   \032u   u   \033u   u   \034u   u   \035u   u   \036u   u   \037u   u   \"u   "u   \\u   \u   \177u   u   \200u   u   \201u   u   \202u   u   \203u   u   \204u   u   \205u   u   \206u   u   \207u   u   \210u   u   \211u   u   \212u   u   \213u   u   \214u   u   \215u   u   \216u   u   \217u   u   \220u   u   \221u   u   \222u   u   \223u   u   \224u   u   \225u   u   \226u   u   \227u   u   \230u   u   \231u   u   \232u   u   \233u   u   \234u   u   \235u   u   \236u   u   \237u   u   \240u    u   \241u   ¡u   \242u   ¢u   \243u   £u   \244u   ¤u   \245u   ¥u   \246u   ¦u   \247u   §u   \250u   ¨u   \251u   ©u   \252u   ªu   \253u   «u   \254u   ¬u   \255u   ­u   \256u   ®u   \257u   ¯u   \260u   °u   \261u   ±u   \262u   ²u   \263u   ³u   \264u   ´u   \265u   µu   \266u   ¶u   \267u   ·u   \270u   ¸u   \271u   ¹u   \272u   ºu   \273u   »u   \274u   ¼u   \275u   ½u   \276u   ¾u   \277u   ¿u   \300u   Àu   \301u   Áu   \302u   Âu   \303u   Ãu   \304u   Äu   \305u   Åu   \306u   Æu   \307u   Çu   \310u   Èu   \311u   Éu   \312u   Êu   \313u   Ëu   \314u   Ìu   \315u   Íu   \316u   Îu   \317u   Ïu   \320u   Ðu   \321u   Ñu   \322u   Òu   \323u   Óu   \324u   Ôu   \325u   Õu   \326u   Öu   \327u   ×u   \330u   Øu   \331u   Ùu   \332u   Úu   \333u   Ûu   \334u   Üu   \335u   Ýu   \336u   Þu   \337u   ßu   \340u   àu   \341u   áu   \342u   âu   \343u   ãu   \344u   äu   \345u   åu   \346u   æu   \347u   çu   \350u   èu   \351u   éu   \352u   êu   \353u   ëu   \354u   ìu   \355u   íu   \356u   îu   \357u   ïu   \360u   ðu   \361u   ñu   \362u   òu   \363u   óu   \364u   ôu   \365u   õu   \366u   öu   \367u   ÷u   \370u   øu   \371u   ùu   \372u   úu   \373u   ûu   \374u   üu   \375u   ýu   \376u   þu   \377u   ÿc                sG   t    f d   |  D  o |  Sd t t t j |  |    d Sd  S(   Nc             3   s   |  ] } |   k Vq d  S(   N(    (   u   .0u   c(   u
   LegalChars(    u)   /mit/python/lib/python3.0/http/cookies.pyu	   <genexpr>   s    u   "(   u   allu	   _nulljoinu   mapu   _Translatoru   get(   u   stru
   LegalChars(    (   u
   LegalCharsu)   /mit/python/lib/python3.0/http/cookies.pyu   _quote   s    u   \\[0-3][0-7][0-7]u   [\\].c             C   s  t  |   d k  o |  S|  d d k p |  d d k o |  S|  d d  }  d } t  |   } g  } xVd | k o
 | k  n o7t j |  |  } t j |  |  } | o$ | o | j |  | d    Pn d } } | o | j d  } n | o | j d  } n | oO | p | | k  o: | j |  | |   | j |  | d  | d } qj | j |  | |   | j t t |  | d | d  d    | d } qj Wt |  S(   Ni   i    u   "ii   i   i   (	   u   lenu
   _OctalPattu   searchu
   _QuotePattu   appendu   startu   chru   intu	   _nulljoin(   u   stru   iu   nu   resu   Omatchu   Qmatchu   ju   k(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   _unquote   s8    " 
  .u   Monu   Tueu   Wedu   Thuu   Friu   Satu   Sunu   Janu   Febu   Maru   Apru   Mayu   Junu   Julu   Augu   Sepu   Octu   Novu   Decc          
   C   so   d d l  m } m  } |   } | | |   \	 } } } }	 }
 } } } } d | | | | | | |	 |
 | f S(   Ni    (   u   gmtimeu   timeu#   %s, %02d-%3s-%4d %02d:%02d:%02d GMT(   u   timeu   gmtime(   u   futureu   weekdaynameu	   monthnameu   gmtimeu   timeu   nowu   yearu   monthu   dayu   hhu   mmu   ssu   wdu   yu   z(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   _getdate-  s
    	+c             B   s   |  Ee  Z i d  d  6d d 6d d 6d d 6d d 6d	 d	 6d
 d
 6d d 6Z d   Z d   Z d   Z e d  Z d d d  Z	 e	 Z
 d   Z d d  Z d d  Z d S(   u   expiresu   Pathu   pathu   Commentu   commentu   Domainu   domainu   Max-Ageu   max-ageu   secureu   httponlyu   Versionu   versionc             C   sB   d  |  _ |  _ |  _ x$ |  j D] } t j |  | d  q! Wd  S(   Nu    (   u   Noneu   keyu   valueu   coded_valueu	   _reservedu   dictu   __setitem__(   u   selfu   K(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   __init__X  s    
 c             C   sG   | j    } | |  j k o t d |   n t j |  | |  d  S(   Nu   Invalid Attribute %s(   u   loweru	   _reservedu   CookieErroru   dictu   __setitem__(   u   selfu   Ku   V(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   __setitem__a  s    c             C   s   | j    |  j k S(   N(   u   loweru	   _reserved(   u   selfu   K(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   isReservedKeyh  s    c                sz   | j    |  j k o t d |   n t   f d   | D  o t d |   n | |  _ | |  _ | |  _ d  S(   Nu!   Attempt to set a reserved key: %sc             3   s   |  ] } |   k Vq d  S(   N(    (   u   .0u   c(   u
   LegalChars(    u)   /mit/python/lib/python3.0/http/cookies.pyu	   <genexpr>q  s    u   Illegal key value: %s(   u   loweru	   _reservedu   CookieErroru   anyu   keyu   valueu   coded_value(   u   selfu   keyu   valu	   coded_valu
   LegalChars(    (   u
   LegalCharsu)   /mit/python/lib/python3.0/http/cookies.pyu   setl  s    		u   Set-Cookie:c             C   s   d | |  j  |  f S(   Nu   %s %s(   u   OutputString(   u   selfu   attrsu   header(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   outputz  s    c             C   s#   d |  j  j |  j t |  j  f S(   Nu   <%s: %s=%s>(   u	   __class__u   __name__u   keyu   repru   value(   u   self(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   __repr__  s    c             C   s   d |  j  |  f S(   Nu   
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        (   u   OutputString(   u   selfu   attrs(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu	   js_output  s    c             C   s  g  } | j  } | d |  j |  j f  | d  k o |  j } n t |  j    } x7| D]/\ } } | d k o q\ n | | k o q\ n | d k o> t |  t d  k o% | d |  j | t |  f  q\ | d k o8 t |  t d  k o | d |  j | | f  q\ | d k o | t	 |  j |   q\ | d k o | t	 |  j |   q\ | d |  j | | f  q\ Wt
 |  S(	   Nu   %s=%su    u   expiresi   u   max-ageu   %s=%du   secureu   httponly(   u   appendu   keyu   coded_valueu   Noneu	   _reservedu   sortedu   itemsu   typeu   _getdateu   stru   _semispacejoin(   u   selfu   attrsu   resultu   RAu   itemsu   Ku   V(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   OutputString  s,    	   &%&N(   u   __name__u
   __module__u	   _reservedu   __init__u   __setitem__u   isReservedKeyu   _LegalCharsu   setu   Noneu   outputu   __str__u   __repr__u	   js_outputu   OutputString(   u
   __locals__(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   Morsel@  s"   


					u   Morselu.   [\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]u   (?x)(?P<key>u$   +?)\s*=\s*(?P<val>"(?:[^\\"]|\\.)*"|u   *)\s*;?c             B   s   |  Ee  Z d    Z d   Z d d  Z d   Z d   Z d d d d  Z e Z	 d   Z
 d d	  Z d
   Z e d  Z d S(   c             C   s
   | | f S(   u
  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.
        (    (   u   selfu   val(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   value_decode  s    c             C   s   t  |  } | | f S(   u   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.
        (   u   str(   u   selfu   valu   strval(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   value_encode  s    c             C   s   | o |  j  |  n d  S(   N(   u   load(   u   selfu   input(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   __init__  s     c             C   s?   |  j  | t    } | j | | |  t j |  | |  d S(   u+   Private method for setting a cookie's valueN(   u   getu   Morselu   setu   dictu   __setitem__(   u   selfu   keyu
   real_valueu   coded_valueu   M(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   __set  s    c             C   s,   |  j  |  \ } } |  j | | |  d S(   u   Dictionary style assignment.N(   u   value_encodeu   _BaseCookie__set(   u   selfu   keyu   valueu   rvalu   cval(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   __setitem__  s    u   Set-Cookie:u   
c             C   sU   g  } t  |  j    } x- | D]% \ } } | j | j | |   q W| j |  S(   u"   Return a string suitable for HTTP.(   u   sortedu   itemsu   appendu   outputu   join(   u   selfu   attrsu   headeru   sepu   resultu   itemsu   Ku   V(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   output  s     c             C   si   g  } t  |  j    } x4 | D], \ } } | j d | t | j  f  q Wd |  j j t |  f S(   Nu   %s=%su   <%s: %s>(   u   sortedu   itemsu   appendu   repru   valueu	   __class__u   __name__u
   _spacejoin(   u   selfu   Lu   itemsu   Ku   V(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   __repr__  s     $c             C   sO   g  } t  |  j    } x* | D]" \ } } | j | j |   q Wt |  S(   u(   Return a string suitable for JavaScript.(   u   sortedu   itemsu   appendu	   js_outputu	   _nulljoin(   u   selfu   attrsu   resultu   itemsu   Ku   V(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu	   js_output  s     c             C   s;   t  |  t  d  k o |  j |  n |  j |  d S(   u   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())
        u    N(   u   typeu   _BaseCookie__ParseStringu   update(   u   selfu   rawdata(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   load  s    c             C   s)  d } t  |  } d  } x
d | k o
 | k  n o | j | |  } | p Pn | j d  | j d  } } | j d  } | d d k o# | o | | | d d   <q q | j   t j k o | o t |  | | <q q |  j	 |  \ }	 }
 |  j
 | |	 |
  |  | } q Wd  S(   Ni    u   keyu   valu   $i   (   u   lenu   Noneu   searchu   groupu   endu   loweru   Morselu	   _reservedu   _unquoteu   value_decodeu   _BaseCookie__set(   u   selfu   stru   pattu   iu   nu   Mu   matchu   Ku   Vu   rvalu   cval(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   __ParseString  s&      N(   u   __name__u
   __module__u   value_decodeu   value_encodeu   Noneu   __init__u   _BaseCookie__setu   __setitem__u   outputu   __str__u   __repr__u	   js_outputu   loadu   _CookiePatternu   _BaseCookie__ParseString(   u
   __locals__(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu
   BaseCookie  s   
	
	
						c             B   s&   |  Ee  Z d  Z d   Z d   Z d S(   u
  SimpleCookie
    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(   N(   u   _unquote(   u   selfu   val(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   value_decodeC  s    c             C   s   t  |  } | t |  f S(   N(   u   stru   _quote(   u   selfu   valu   strval(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   value_encodeE  s    N(   u   __name__u
   __module__u   __doc__u   value_decodeu   value_encode(   u
   __locals__(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   SimpleCookie<  s   
	c              C   s(   d d  l  }  d d  l } |  j | j  S(   Ni    (   u   doctestu   http.cookiesu   testmodu   cookies(   u   doctestu   http(    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   _testM  s    u   __main__($   u   __doc__u   stringu   pickleu   dumpsu   loadsu   reu   warningsu   __all__u   joinu	   _nulljoinu   _semispacejoinu
   _spacejoinu	   Exceptionu   CookieErroru   ascii_lettersu   digitsu   _LegalCharsu   _Translatoru   _quoteu   compileu
   _OctalPattu
   _QuotePattu   _unquoteu   _weekdaynameu   Noneu
   _monthnameu   _getdateu   dictu   Morselu   _LegalCharsPattu   ASCIIu   _CookiePatternu
   BaseCookieu   SimpleCookieu   _testu   __name__(    (    (    u)   /mit/python/lib/python3.0/http/cookies.pyu   <module>   s   				2y	o	