N
?;c       se    d  Z    k Z k Z  k l  k l  k Z  y  k l l	 Wn#  e
 j
 o  k l l	 n X y  k Z Wn"  e
 j
 o  e
 d  n X d e f d     YZ  e i e i d Z  e i e i e i e  Z  h  d d <d d <d	 d
 <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d  <d! d" <d# d$ <d% d& <d' d( <d) d* <d+ d, <d- d. <d/ d0 <d1 d2 <d3 d4 <d5 d6 <d7 d8 <d9 d: <d; d< <d= d> <d? d@ <dA dB <dC dD <dE dE <dF dF <dG dH <dI dI <dJ dJ <dK dK <dL dL <dM dM <dN dN <dO dO <dP dP <dQ dQ <dR dR <dS dS <dT dT <dU dU <dV dV <dW dW <dX dX <dY dY <dZ dZ <d[ d[ <d\ d\ <d] d] <d^ d^ <d_ d_ <d` d` <da da <db db <d` d` <dc dc <dd dd <de de <df df <dg dg <dh dh <di di <dj dj <dk dk <dl dl <dm dm <dn dn <do do <dp dp <dq dq <dr dr <ds ds <dt dt <du du <dv dv <dw dw <dx dx <dy dy <dz dz <d{ d{ <d| d| <d} d} <d~ d~ <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <dd<dd<dd<dd<d	d
<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd <d!d"<d#d$<d%d&<d'd(<d)d*<d+d,<d-d.<d/d0<d1d2<d3d4<d5d6<d7d8<d9d:<d;d<<d=d><d?d@<dAdB<dCdD<dEdF<dGdH<dIdJ<dKdL<dMdN<dOdP<dQdR<dSdT<dUdV<dWdX<dYdZ<d[d\<d]d^<d_d`<dadb<dcdd<dedf<dgdh<didj<dkdl<dmdn<dodp<dqdr<dsdt<dudv<dwdx<dydz<d{d|<d}d~<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<dd<Z  e d Z  e i d Z e i d Z e i d Z 
d  Z =e d Z De	 d Z Udddddddg Z We  ddddddddddddg Z! [de e! d Z" ldZ# mdZ$ ne i de# de# d Z% e i de# de$ d Z& de f d    YZ' \de f d    YZ( dS(  sd  
Here's a sample session to show how to use this module.
At the moment, this is the only documentation.

Importing is easy..

   >>> import Cookie

Most of the time you start by creating a cookie.  The __init__
routine can take several arguments, but that isn't covered here.

   >>> C = Cookie.Cookie()

Now, you can add values to the Cookie just as is if it were a
dictionary.

   >>> C["joe"] = "a cookie"
   >>> C
   Set-Cookie: joe="a cookie";

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 by using the
the .output() function

   >>> C.output("Cookie:")
   'Cookie: joe="a cookie";'


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.load("mary=hadalittlelamb;")
   >>> C
   Set-Cookie: mary=hadalittlelamb;
   Set-Cookie: joe="a cookie";

Each element of the Cookie also supports all of the RFC 2109
Cookie attributes.  Here's an example which sets the Path
attribute.

   >>> C["joe"]["path"] = "/home/joe"
   >>> C
   Set-Cookie: mary=hadalittlelamb;
   Set-Cookie: joe="a cookie"; Path=/home/joe;

Before I forget, the .load() method is pretty smart about
identifying a cookie.  Escaped quotation marks and nested
semicolons do not confuse it.

   >>> C.load('lobotomy="joe=wolf; lobotomy=\"nested quote\"; mark=\012;";')
   >>> C
   Set-Cookie: mary=hadalittlelamb;
   Set-Cookie: joe="a cookie"; Path=/home/joe;
   Set-Cookie: lobotomy="joe=wolf; lobotomy="nested quote"; mark=
;";


Each dictionary element has a 'value' attribute, which gives you
back the value associated with the key.

   >>> C["joe"].value
   'a cookie'
   >>> C["lobotomy"].value
   'joe=wolf; lobotomy="nested quote"; mark=
;'

If you set a cookie to a non-string object, that object is
automatically pickled (using cPickle or pickle) in the
Set-Cookie: header.

   >>> C["int"] = 7
   >>> C
   Set-Cookie: lobotomy="joe=wolf; lobotomy="nested quote"; mark=
;";
   Set-Cookie: joe="a cookie"; Path=/home/joe;
   Set-Cookie: mary=hadalittlelamb;
   Set-Cookie: int="I7
.";

If the .load() method finds a pickled object in the string, then
it automatically unpickles it.  The 'value' attribute gives you back
the true value, not the encoded representation.


   >>> C.load('anotherint="I45\012.";')

   >>> C["anotherint"].value
   45
   >>> C["int"].value
   7

   >>> C
   Set-Cookie: lobotomy="joe=wolf; lobotomy="nested quote"; mark=
;";
   Set-Cookie: joe="a cookie"; Path=/home/joe;
   Set-Cookie: mary=hadalittlelamb;
   Set-Cookie: anotherint="I45
.";
   Set-Cookie: int="I7
.";

Finally, the encoding/decoding behavior is controllable by
two attributes of the Cookie:

  net_setfunc()    Takes in an encoded string and returns a value
  user_setfunc()   Takes in a value and returns the encoded string

By default, these functions are defined in the Cookie module, but
you should feel free to override them.

   >>> C.net_setfunc
   <function _debabelize at c1558>
   >>> C.user_setfunc
   <function _babelize at c1530>

Finis.
s0   Cookie.py requires 're' from Python 1.5 or laters   CookieErrorc      s     RS(   N(    (    s   ./Cookie.pys   CookieError s   s   !#$%&'*+-.^_`|~s   \000s    s   \001s   s   \002s   s   \003s   s   \004s   s   \005s   s   \006s   s   \007s   s   \010s   s   \011s   	s   \012s   
s   \013s   s   \014s   s   \015s   s   \016s   s   \017s   s   \020s   s   \021s   s   \022s   s   \023s   s   \024s   s   \025s   s   \026s   s   \027s   s   \030s   s   \031s   s   \032s   s   \033s   s   \034s   s   \035s   s   \036s   s   \037s   s    s   !s   \"s   "s   #s   $s   %s   &s   's   (s   )s   *s   +s   ,s   -s   .s   /s   0s   1s   2s   3s   4s   5s   6s   7s   8s   9s   :s   ;s   <s   >s   ?s   @s   As   Bs   Cs   Ds   Es   Fs   Gs   Hs   Is   Js   Ks   Ls   Ms   Ns   Os   Ps   Qs   Rs   Ss   Ts   Us   Vs   Ws   Xs   Ys   Zs   [s   \\s   \s   ]s   ^s   _s   \074s   =s   `s   as   bs   cs   ds   es   fs   gs   hs   is   js   ks   ls   ms   ns   os   ps   qs   rs   ss   ts   us   vs   ws   xs   ys   zs   {s   |s   }s   ~s   \177s   s   \200s   s   \201s   s   \202s   s   \203s   s   \204s   s   \205s   s   \206s   s   \207s   s   \210s   s   \211s   s   \212s   s   \213s   s   \214s   s   \215s   s   \216s   s   \217s   s   \220s   s   \221s   s   \222s   s   \223s   s   \224s   s   \225s   s   \226s   s   \227s   s   \230s   s   \231s   s   \232s   s   \233s   s   \234s   s   \235s   s   \236s   s   \237s   s   \240s   s   \241s   s   \242s   s   \243s   s   \244s   s   \245s   s   \246s   s   \247s   s   \250s   s   \251s   s   \252s   s   \253s   s   \254s   s   \255s   s   \256s   s   \257s   s   \260s   s   \261s   s   \262s   s   \263s   s   \264s   s   \265s   s   \266s   s   \267s   s   \270s   s   \271s   s   \272s   s   \273s   s   \274s   s   \275s   s   \276s   s   \277s   s   \300s   s   \301s   s   \302s   s   \303s   s   \304s   s   \305s   s   \306s   s   \307s   s   \310s   s   \311s   s   \312s   s   \313s   s   \314s   s   \315s   s   \316s   s   \317s   s   \320s   s   \321s   s   \322s   s   \323s   s   \324s   s   \325s   s   \326s   s   \327s   s   \330s   s   \331s   s   \332s   s   \333s   s   \334s   s   \335s   s   \336s   s   \337s   s   \340s   s   \341s   s   \342s   s   \343s   s   \344s   s   \345s   s   \346s   s   \347s   s   \350s   s   \351s   s   \352s   s   \353s   s   \354s   s   \355s   s   \356s   s   \357s   s   \360s   s   \361s   s   \362s   s   \363s   s   \364s   s   \365s   s   \366s   s   \367s   s   \370s   s   \371s   s   \372s   s   \373s   s   \374s   s   \375s   s   \376s   s   \377s   c    s     | |  Sd  S(   N(   s   tables   c(   s   cs   tables   ./Cookie.pys
   _translate s   c    s`     x2 t  d  r }  | |  j o  Pn q W |  Sd | t t |   d  d Sd  S(   Ni    s   "s    (   s   _SpecialCharss   Cs   strs   joins   maps
   _translate(   s   strs   joins   Cs   ./Cookie.pys   _quote s    	s   \\[0-3][0-7][0-7]s   [\\].c    s%  
t  |   d j  o |  Sn |  d d j p |  d d j o |  Sn |  d d !}  d } t  |   } g  } xd | j o
 | j  n o_ t i |  |  } !t i |  |  } "| o | o #| i
 |  |  $Pn &d } } '| o '| i d  } n (| o (| i d  } n )| o | p
 | | j  o@ *| i
 |  | | ! +| i
 |  | d  ,| d } nV .| i
 |  | | ! /| i
 t t i |  | d | d !d    0| d } q W1t i | d  Sd  S(   Ni   i    s   "i   i   i   s    (   s   lens   strs   is   ns   ress
   _OctalPatts   searchs   Omatchs
   _QuotePatts   Qmatchs   appends   js   ks   starts   chrs   strings   atois   join(   s   strs   is   ns   ress   Omatchs   Qmatchs   js   ks   ./Cookie.pys   _unquote
s8   &		 !
 
 1c    sG   =>t  |   t  d  j o ?t |   Sn At | |    Sd  S(   Ns    (   s   types   vals   _quotes   dumps(   s   vals   dumpss   ./Cookie.pys	   _babelize=s   c    sf   DEt  |   } F| p | d d j o F| Sn Gy H| |  SWn IJ| Sn Xd  S(   Ni   s   .(   s   _unquotes   vals   strs   loads(   s   vals   loadss   strs   ./Cookie.pys   _debabelizeDs    s   Mons   Tues   Weds   Thus   Fris   Sats   Suns   Jans   Febs   Mars   Aprs   Mays   Juns   Juls   Augs   Seps   Octs   Novs   Decc  	  sv   [\k  l l  ]|   } ^| | |   \	 } } } }	 }
 } } } } _d | | | | | | |	 |
 | f Sd  S(   Ns#   %s, %02d-%3s-%4d %02d:%02d:%02d GMT(   s   times   gmtimes   nows   futures   years   months   days   hhs   mms   sss   wds   ys   zs   weekdaynames	   monthname(   s   futures   weekdaynames	   monthnames   gmtimes   times   nows   years   months   days   hhs   mms   sss   wds   ys   zs   ./Cookie.pys   _getdate[s   .i    s0   [\w\d\n\r!#%'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{]+s5   [\, \w\d\n\r!#%'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{=&]+s   (?x)(?P<key>s#   )(\s*=\s*(?P<val>"(?:[^\\"]|\\.)*"|s   )\s*)?;?s   Morselc      s   h  d d <d d <d d <d d <d d	 <d
 d
 <d d <Z  e  i   Z e d  Z d   Z d   Z d   Z d   Z d d  Z	 e	 Z
 d   Z d   Z e d  Z RS(   Ns   expiress   Paths   paths   Comments   comments   Domains   domains   Max-Ages   max-ages   secures   Versions   versionc    s   t  |  _ |  _ |  _ t i |   d |  _ t  |  _ x, |  i	 d r } t i |  | d  qT W| o |  i |  n d  S(   Ni    s    (   s   Nones   selfs   keys   values   coded_values   UserDicts   __init__s   _clears   _headers   _Morsel__reserved_keyss   Ks   __setitem__s   inputs	   parse_set(   s   selfs   inputs   Ks   ./Cookie.pys   __init__s    	
c    sZ   t  i |  } | |  i j o t d |   n t i |  | |  d  S(   Ns   Invalid Attribute %s(	   s   strings   lowers   Ks   selfs   _Morsel__reserved_keyss   CookieErrors   UserDicts   __setitem__s   V(   s   selfs   Ks   Vs   ./Cookie.pys   __setitem__s   c    sg   t  i |  } | |  i j o t d |   n t i |  | |  |  | } d  S(   Ns   Invalid Attribute %s(
   s   strings   lowers   Ks   selfs   _Morsel__reserved_keyss   CookieErrors   UserDicts   __setitem__s   Vs   d(   s   selfs   Ks   Vs   ds   ./Cookie.pys   setitems
   c    sR   t  i |  |  i j o d  Sn | |  _ | |  _ | |  _ d  S(   N(	   s   strings   lowers   keys   selfs   _Morsel__reserved_keyss   vals   values	   coded_vals   coded_value(   s   selfs   keys   vals	   coded_vals   ./Cookie.pys   sets
   c    s   d |  _ d  S(   Ni   (   s   selfs   _clear(   s   selfs   ./Cookie.pys   clearMorsels   c    s6   | |  _ d | |  i   f St |  _ d  S(   Ns   %s %s(   s   headers   selfs   _headers   OutputStrings   None(   s   selfs   headers   ./Cookie.pys   outputs   s   Set-Cookie:c    s   d |  i   f Sd  S(   Ns   
        <SCRIPT LANGUAGE="JavaScript">
        <!-- begin hiding
        document.cookie = "%s"
        // end hiding -->
        </script>
        (   s   selfs   OutputString(   s   selfs   ./Cookie.pys	   js_outputs   c  	  sF  g  } | i } | d |  i |  i f  x|  i   d r\ } } | o
 qG n | d j o t	 |  t	 d  j o( | d |  i
 | t |  f  n | d j o t	 |  t	 d  j o" | d |  i
 | | f  nK  | d j o | d |  i
 |  n | d |  i
 | | f  qG W|  i o |  i ot i |  d	  oxt |  d	 d r} 	| d
 |  i  
| d |  i |  i f  xL|  i   d r9\ } } | o
 qn | d j o t	 |  t	 d  j o( | d |  i
 | t |  f  n | d j o t	 |  t	 d  j o" | d |  i
 | | f  n} | d j o | d |  i
 |  nQ | d	 j o" | d |  i
 | | f  n | d |  i
 | | f  qWqWn n t i | d  Sd  S(   Ns   %s=%s;i    s   expiresi   s   max-ages   %s=%d;s   secures   %s;s   domains   
%ss    (   s   results   appends   RAs   selfs   keys   coded_values   itemss   Ks   Vs   types   _Morsel__reserveds   _getdates   _clears   _headers   cookieClearMaps   has_keys   domains   strings   join(   s   selfs   results   RAs   Ks   Vs   domains   ./Cookie.pys   OutputStringsD   	  
)()"" 	  
)()"".c 
   s  h  } #t d |  %d } &t |  } 'd } )x)d | j o
 | j  n o,| i | |  } -| o -Pn /| i
 d  | i
 d  f \ } }	 0| i d  } 2t i |	  }	 4|	 t j o 5d | | <n 7|	 d j o
 8qD n ?y# @|	 |  t i |  <Ad } Wn Bt j
 o Cd } n XF| d d j o' Gd } H|	 |  t i | d  <n L| oK M|  i o& N|  i | t t |	 f  |	  n Pt d |   n qD Wd  S(	   Ns   Morsel.parse_set (%s)i    s   keys   vali   s   XXXXs   $s   Invalid Attribute %s(   s   ignore_lists   logs   strs   is   lens   ns   not_attrs   patts   searchs   matchs   groups   Ks   Vs   ends   strings   strips   Nones   selfs   lowers   CookieErrors   keys   sets   applys   _debabelize(
   s   selfs   strs   patts   ignore_lists   is   ns   not_attrs   matchs   Ks   Vs   ./Cookie.pys	   parse_sets:   			 ! '
	
&(   s   _Morsel__reserveds   keyss   _Morsel__reserved_keyss   Nones   __init__s   __setitem__s   setitems   sets   clearMorsels   outputs   __repr__s	   js_outputs   OutputStrings   _SetCookiePatterns	   parse_set(    s   ./Cookie.pys   Morsels   H
		-s   Cookiec    	  s   \`e  Z be  e e d d d d d d  Z d   Z d   Z d d d e  d  Z d	   Z d d
  Z	 e	 Z
 d   Z d   Z e d  Z RS(   Nc	 
   s   bh| |  _  i| |  _ jt i |   k| o k|  i |  n m| |  _ n| |  _ o| |  _	 p| |  _
 q| |  _ vd |  _ w|  i t j o xt i d  |  _ n y|  i i |  }	 z|	 o {d |  _ n d  S(   Ni    s   MSIE 3.0i   (   s   net_setfuncs   selfs   user_setfuncs   UserDicts   __init__s   inputs   loads   domains   expiress   paths   maxages   browsers   old_browsers   old_browser_res   Nones   res   compiles   searchs   m(
   s   selfs   inputs   net_setfuncs   user_setfuncs   domains   paths   expiress   maxages   browsers   ms   ./Cookie.pys   __init__bs    
 
s    s   /s   Thu, 15 Apr 2010 20:00:00 GMTi3c    so   t  |  t  |  i  j o t |  i |  Sn3 | t j o d Sn t |  i | i  Sd  S(   Ni   (   s   types   dicts   selfs   datas   cmps   None(   s   selfs   dicts   ./Cookie.pys   __cmp__s
   c    s   |  i | t    } | i | | t |  i | f   |  i	 o |  i	 | d <n |  i
 o |  i
 | d <n |  i o |  i | d <n |  i o |  i o |  i | d <n t i |  | |  d S(   s   Dictionary style assignment.s   domains   paths   expiress   max-ageN(   s   selfs   gets   keys   Morsels   Ms   sets   values   applys   user_setfuncs   domains   paths   expiress   old_browsers   maxages   UserDicts   __setitem__(   s   selfs   keys   values   Ms   ./Cookie.pys   __setitem__s   %    c    s  |  i | t    } | i | | t |  i | f   | d j o | | d <n |  i	 | d <| o | | d <n | o | | d <n |  i o5 | t j o |  i | d <n | | d <n t i |  | |  d S(   s   Dictionary style assignment.s    s   domains   paths   expiress   max-ageN(   s   selfs   gets   keys   Morsels   Ms   sets   values   applys   user_setfuncs   domains   paths   expiress   old_browsers   maxages   Nones   UserDicts   __setitem__(   s   selfs   keys   values   domains   paths   expiress   maxages   Ms   ./Cookie.pys   setitems   % 
 
 c    s]   |  i | d d d |  i o d |  | d <n |  | } | i   d  S(   Ns    s   expiress   Sat, 09-Nov-70 00:01:00 GMTs   0s   max-age(   s   selfs   setitems   keys   old_browsers   Ms   clearMorsel(   s   selfs   keys   Ms   ./Cookie.pys   clearCookies
   c    sd   g  } x8 |  i   d r% \ } } | i | i |   q! Wt i	 | d  Sd S(   s"   Return a string suitable for HTTP.i    s   
N(
   s   results   selfs   itemss   Ks   Vs   appends   outputs   headers   strings   join(   s   selfs   headers   results   Ks   Vs   ./Cookie.pys   outputs   	 s   Set-Cookie:c    sa   g  } x5 |  i   d r" \ } } | i | i    q! Wt i | d  Sd S(   s(   Return a string suitable for JavaScript.i    s    N(	   s   results   selfs   itemss   Ks   Vs   appends	   js_outputs   strings   join(   s   selfs   results   Ks   Vs   ./Cookie.pys	   js_outputs   	 c    s   t  |  t  d  j o |  i |  nK xD | i   d r1 \ } } |  i |  o | |  | <n qH Wd Sd S(   s4  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())
        Unfortunately, this does NOT allow merging of two Cookie
        dictionaries!
        s    i    N(   s   types   rawdatas   selfs   _Cookie__ParseStrings   itemss   Ks   Vs   has_key(   s   selfs   rawdatas   Ks   Vs   ./Cookie.pys   loads    c    s  h  } d } t |  } t } d } xd | j o
 | j  n o| i	 | |  } | o Pn | i d  | i d  f \ }	 }
 | i d  } |
 t j o d | |	 <n | oL y# |
 | t i |	  <d } Wn t j
 o d } n Xn | p | o |	 d d j o | o |
 | t i |	 d  <nq |  i |	  o | i |	  oK t   } | i |	 t |  i |
 f  |
  	t i |  |	 |  n n q< Wd  S(   Ni    s   keys   vali   s   $(   s   ignore_lists   is   lens   strs   ns   Nones   Ms   not_attrs   patts   searchs   matchs   groups   Ks   Vs   ends   strings   lowers   CookieErrors   selfs   has_keys   Morsels   sets   applys   net_setfuncs   UserDicts   __setitem__(   s   selfs   strs   patts   ignore_lists   is   ns   Ms   not_attrs   matchs   Ks   Vs   ./Cookie.pys   __ParseStrings6   				 ! '
%%(   s   Nones   old_browser_res   _debabelizes	   _babelizes   __init__s   __cmp__s   __setitem__s   setitems   clearCookies   outputs   __repr__s	   js_outputs   loads   _CookiePatterns   _Cookie__ParseString(    s   ./Cookie.pys   Cookie\s   	$
	N()   s   __doc__s   strings   syss   UserDicts   logs   *s   urllibs   cPickles   dumpss   loadss   ImportErrors   pickles   res	   Exceptions   CookieErrors   letterss   digitss   _LegalCharss	   translates   _idmaps   _SpecialCharss   _Translators
   _translates   joins   _quotes   compiles
   _OctalPatts
   _QuotePatts   _unquotes	   _babelizes   _debabelizes   _weekdaynames   Nones
   _monthnames   _getdates   _LegalCharsPatts   _SetCharsPatts   _CookiePatterns   _SetCookiePatterns   Morsels   Cookie(    s   ./Cookie.pys   ? sR   

	D         30		""