PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  oY>S @s dZddlZddlZdddgZdjZdjZdjZd d ZGd dde Z ej ej d Z e d ZddeedeeeeDZejeddeddiejdeje jZddZejdZejdZddZddddd d!d"gZdd#d$d%d&d'd(d)d*d+d,d-d.g Zdeed/d0ZGd1d2d2e Z!d3Z"e"d4Z#ejd5e"d6e#d7ej$Z%Gd8dde Z&Gd9dde&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 SimpleCookiez;  cCs0ddl}d|}|j|tdddS)NrzvThe .%s setter is deprecated. The attribute will be read-only in future releases. Please use the set() method instead. stacklevel)warningswarnDeprecationWarning)setterr msgr&/opt/python35/lib/python3.5/cookies.py_warn_deprecated_setters rc@seZdZdS)rN)__name__ __module__ __qualname__rrrrrs z!#$%&'*+-.^_`|~:z ()/<=>?@[]{}cCsi|]}d||qS)z\%03or).0nrrr s r"z\"\z\\z[%s]+cCs5|dkst|r|Sd|jtdSdS)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. Nr) _is_legal_key translate _Translator)strrrr_quotesrz\\[0-3][0-7][0-7]z[\\].cCs|dkst|dkr"|S|ddksB|ddkrF|S|dd}d}t|}g}x?d|ko|knrtj||}tj||}| r| r|j||dPd }}|r|jd}|r |jd}|r]| s$||kr]|j||||j||d|d}qq|j||||jtt||d|dd|d}qqWt|S) Nrrr#r#) len _OctalPattsearch _QuotePattappendstartchrint _nulljoin)rirresZo_matchZq_matchjkrrr_unquotes6    .r1ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc Csoddlm}m}|}|||\ }}}} } } } } }d|| ||||| | | fS)Nr)gmtimetimez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r3r2)futureZ weekdaynameZ monthnamer2r3ZnowZyearZmonthZdayZhhZmmssZwdyzrrr_getdates  +r8c@seZdZdZddddddddd d d d d dddiZd d hZddZeddZej ddZeddZ e j ddZ eddZ e j ddZ ddZ ddd Z d!d"ZejZd#d$Zd%d&Zd'd(Zed)d*Zd+d,Zd-d.Zdd/d0d1ZeZd2d3Zdd4d5Zdd6d7ZdS)8MorselaA 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. expirespathZPathZcommentCommentdomainZDomainzmax-agezMax-AgeZsecureZSecureZhttponlyZHttpOnlyversionZVersioncCsBd|_|_|_x$|jD]}tj||dq!WdS)Nr)_key_value _coded_value _reserveddict __setitem__)selfkeyrrr__init__&szMorsel.__init__cCs|jS)N)r?)rErrrrF.sz Morsel.keycCstd||_dS)NrF)rr?)rErFrrrrF2s cCs|jS)N)r@)rErrrvalue7sz Morsel.valuecCstd||_dS)NrH)rr@)rErHrrrrH;s cCs|jS)N)rA)rErrr coded_value@szMorsel.coded_valuecCstd||_dS)NrI)rrA)rErIrrrrIDs cCsE|j}||jkr.td|ftj|||dS)NzInvalid attribute %r)lowerrBrrCrD)rEKVrrrrDIs zMorsel.__setitem__NcCsA|j}||jkr.td|ftj|||S)NzInvalid attribute %r)rJrBrrC setdefault)rErFvalrrrrMOs zMorsel.setdefaultcCsYt|tstStj||oX|j|jkoX|j|jkoX|j|jkS)N) isinstancer9NotImplementedrC__eq__r@r?rA)rEmorselrrrrQUs z Morsel.__eq__cCs0t}tj|||jj|j|S)N)r9rCupdate__dict__)rErRrrrcopy_s z Morsel.copycCsui}xXt|jD]D\}}|j}||jkrStd|f|||) __class__rr_)rErrr__repr__szMorsel.__repr__cCsd|j|jddS)Nz rz\")r_replace)rEr`rrr js_outputszMorsel.js_outputcCsQg}|j}|d|j|jf|dkr>|j}t|j}x|D]\}}|dkrrqW||krqW|dkrt|tr|d|j|t|fqW|dkrt|tr|d|j||fqW||j kr(|rC|t |j|qW|d|j||fqWWt |S)Nz%s=%srr:zmax-agez%s=%d) r(rFrIrBsortedrVrOr+r8_flagsr_semispacejoin)rEr`resultr(rVrFrHrrrr_s(     $zMorsel.OutputString)rrr__doc__rBrhrGpropertyrFr rHrIrDrMrQobject__ne__rUrSrYrZr[r\r^rb__str__rdrfr_rrrrr9s@             r9z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z (?x) # This is a verbose pattern \s* # Optional whitespace at start of cookie (?P # 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 # 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@seZdZdZddZddZdddZd d Zd d Zdd dddZ e Z ddZ dddZ ddZ eddZdS)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)rErNrrr value_decodeszBaseCookie.value_decodecCst|}||fS)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)rErNstrvalrrr value_encodes zBaseCookie.value_encodeNcCs|r|j|dS)N)load)rEinputrrrrGszBaseCookie.__init__cCs?|j|t}|j|||tj|||dS)z+Private method for setting a cookie's valueN)getr9r[rCrD)rErFZ real_valuerIMrrrZ__setszBaseCookie.__setcCsQt|tr%tj|||n(|j|\}}|j|||dS)zDictionary style assignment.N)rOr9rCrDrr_BaseCookie__set)rErFrHrvalcvalrrrrDszBaseCookie.__setitem__z Set-Cookie:z cCsUg}t|j}x-|D]%\}}|j|j||qW|j|S)z"Return a string suitable for HTTP.)rgrVr(rbjoin)rEr`raseprjrVrFrHrrrrb s zBaseCookie.outputcCsig}t|j}x4|D],\}}|jd|t|jfqWd|jjt|fS)Nz%s=%sz<%s: %s>)rgrVr(reprrHrcr _spacejoin)rElrVrFrHrrrrds $zBaseCookie.__repr__cCsOg}t|j}x*|D]"\}}|j|j|qWt|S)z(Return a string suitable for JavaScript.)rgrVr(rfr,)rEr`rjrVrFrHrrrrfs zBaseCookie.js_outputcCsJt|tr|j|n'x$|jD]\}}|||sB        )   2