Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/future/backports/http/ |
| [Home] [System Details] [Kill Me] |
�
,�]c
@`s�dZddlmZddlmZddlmZddlmZddlmZmZm Z m
Z
ddlmZm
Z
ddlZer�de_nddlZd d
dgZdjZd
jZdjZdefd��YZejejdZi�dd6dd6dd6dd6dd6dd6dd6d
d!6d"d#6d$d%6d&d'6d(d)6d*d+6d,d-6d.d/6d0d16d2d36d4d56d6d76d8d96d:d;6d<d=6d>d?6d@dA6dBdC6dDdE6dFdG6dHdI6dJdK6dLdM6dNdO6dPdQ6dRdS6dTdU6dVdW6dXdY6dZd[6d\d]6d^d_6d`da6dbdc6ddde6dfdg6dhdi6djdk6dldm6dndo6dpdq6drds6dtdu6dvdw6dxdy6dzd{6d|d}6d~d6d�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�6dd6dd6dd6dd6dd 6d
d6dd
6dd6dd6dd6dd6dd6dd6dd6dd6dd6d
d!6d"d#6d$d%6d&d'6d(d)6d*d+6d,d-6d.d/6d0d16d2d36d4d56d6d76d8d96d:d;6d<d=6d>d?6d@dA6dBdC6dDdE6dFdG6dHdI6dJdK6dLdM6dNdO6dPdQ6dRdS6dTdU6dVdW6dXdY6dZd[6Zed\�Zejd]�Zejd^�Zd_�Z
d`dadbdcdddedfgZ!ddgdhdidjdkdldmdndodpdqdrg
Z#de!e#ds�Z$dtefdu��YZ%dvZ&ejdwe&dxe&dyej�Z'dzefd{��YZ(d|e(fd}��YZ)dS(~uf
http.cookies module ported to python-future from Py3.3
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(tunicode_literals(tprint_function(tdivision(tabsolute_import(tchrtdicttinttstr(tPY2t
as_native_strNuCookieErroru
BaseCookieuSimpleCookieuu; u tCookieErrorcB`seZRS((t__name__t
__module__(((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyR
�su!#$%&'*+-.^_`|~:u\000uu\001uu\002uu\003uu\004uu\005uu\006uu\007uu\010uu\011u u\012u
u\013uu\014uu\015u
u\016uu\017uu\020uu\021uu\022uu\023uu\024uu\025uu\026uu\027uu\030uu\031uu\032uu\033uu\034uu\035uu\036uu\037uu\054u,u\073u;u\"u"u\\u\u\177uu\200uu\201uu\202uu\203uu\204uu\205u
u\206uu\207uu\210uu\211uu\212uu\213uu\214uu\215uu\216uu\217uu\220uu\221uu\222uu\223uu\224uu\225uu\226uu\227uu\230uu\231uu\232uu\233uu\234uu\235uu\236uu\237uu\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\255uu\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`s@t�fd�|D��r
|Sdtd�|D��dSdS(u�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.
c3`s|]}|�kVqdS(N((t.0tc(t
LegalChars(sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pys <genexpr>�su"cs`s!|]}tj||�VqdS(N(t_Translatortget(R
ts((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pys <genexpr>�sN(tallt _nulljoin(RR((RsA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyt_quote�su\\[0-3][0-7][0-7]u[\\].cC`s�t|�dkr|S|ddks6|ddkr:|S|dd!}d}t|�}g}x9d|koy|knr�tj||�}tj||�}|r�|r�|j||�Pnd}}|r�|jd�}n|r�|jd�}n|rN|s||krN|j|||!�|j||d�|d}qb|j|||!�|jtt||d|d!d���|d}qbWt|�S(Niiu"i����iii( tlent
_OctalPatttsearcht
_QuotePatttappendtstartRRR(tmystrtitntresto_matchtq_matchtjtk((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyt_unquote�s6
+uMonuTueuWeduThuuFriuSatuSunuJanuFebuMaruApruMayuJunuJuluAuguSepuOctuNovuDecc C`soddlm}m}|�}|||�\ }}}} }
}}}
}d||||||| |
|fS(Ni(tgmtimettimeu#%s, %02d %3s %4d %02d:%02d:%02d
GMT(R&R%(tfuturetweekdaynamet monthnameR%R&tnowtyeartmonthtdaythhtmmtsstwdtytz((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyt_getdate3s
+tMorselcB`s�eZdZidd6dd6dd6dd6dd 6d
d
6dd6dd
6Zed
dg�Zd�Zd�Zd�Ze d�Zddd�ZeZe
�d��Zdd�Zdd�ZRS(u�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.
uexpiresuPathupathuCommentucommentuDomainudomainuMax-Ageumax-ageusecureuhttponlyuVersionuversioncC`sBd|_|_|_x$|jD]}tj||d�q!WdS(Nu(tNonetkeytvaluetcoded_valuet _reservedRt__setitem__(tselfR7((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyt__init__^scC`sE|j�}||jkr.td|��ntj|||�dS(NuInvalid
Attribute %s(tlowerR:R
RR;(R<tKtV((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyR;fscC`s|j�|jkS(N(R>R:(R<R?((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyt
isReservedKeylsc`sv|j�|jkr(td|��nt�fd�|D��rWtd|��n||_||_||_dS(Nu!Attempt
to set a reserved key:
%sc3`s|]}|�kVqdS(N((R
R(R(sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pys <genexpr>tsuIllegal
key value: %s(R>R:R
tanyR7R8R9(R<R7tvalt coded_valR((RsA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pytsetos uSet-Cookie:cC`sd||j|�fS(Nu%s
%s(tOutputString(R<tattrstheader((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pytoutput|scC`sYtr*t|jt�r*t|j�}n |j}d|jjt|j�t|�fS(Nu<%s:
%s=%s>( Rt
isinstanceR8tunicodeRt __class__RR7trepr(R<RC((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyt__repr__�s
cC`sd|j|�jdd�S(Nu�
<script type="text/javascript">
<!-- begin hiding
document.cookie = "%s";
// end hiding -->
</script>
u"u\"(RFtreplace(R<RG((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyt js_output�scC`swg}|j}|d|j|jf�|dkrA|j}nt|j��}x|D]\}}|dkrxqZn||kr�qZn|dkr�t|t�r�|d|j|t |�f�qZ|dkrt|t�r|d|j||f�qZ|dkr(|t
|j|��qZ|dkrN|t
|j|��qZ|d|j||f�qZWt|�S(Nu%s=%suuexpiresumax-ageu%s=%dusecureuhttponly(RR7R9R6R:tsortedtitemsRJRR4Rt_semispacejoin(R<RGtresultRRRR7R8((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyRF�s* $N(RRt__doc__R:REt_flagsR=R;RAt_LegalCharsR6RIt__str__R RNRPRF(((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyR5;s(
u.[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]u~
(?x) # This is a verbose pattern
(?P<key> # Start of group 'key'
u+? # 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
u,* # 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.
t
BaseCookiecB`s�eZdZd�Zd�Zd
d�Zd�Zd�Zd
ddd�Z e Z
e�d ��Zd
d
�Z
d�Zed�ZRS(u'A container class for a set of
Morsels.cC`s
||fS(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.
((R<RC((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pytvalue_decode�scC`st|�}||fS(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.
(R(R<RCtstrval((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pytvalue_encode�scC`s|r|j|�ndS(N(tload(R<tinput((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyR=�scC`s?|j|t��}|j|||�tj|||�dS(u+Private
method for setting a cookie's valueN(RR5RERR;(R<R7t
real_valueR9tM((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyt__set�scC`s,|j|�\}}|j|||�dS(uDictionary
style
assignment.N(R\t_BaseCookie__set(R<R7R8trvaltcval((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyR;�suSet-Cookie:u
cC`sUg}t|j��}x-|D]%\}}|j|j||��qW|j|�S(u"Return
a string suitable for
HTTP.(RQRRRRItjoin(R<RGRHtsepRTRRR7R8((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyRI�s
cC`s�g}t|j��}xj|D]b\}}trUt|jt�rUt|j�}n |j}|jdt|�t|�f�qWd|j j
t|�fS(Nu%s=%su<%s: %s>(RQRRRRJR8RKRRRMRLRt
_spacejoin(R<tlRRR7R8RC((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyRNs 'cC`sOg}t|j��}x*|D]"\}}|j|j|��qWt|�S(u(Return
a string suitable for
JavaScript.(RQRRRRPR(R<RGRTRRR7R8((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyRPs
cC`sJt|t�r|j|�n'x$|j�D]\}}|||<q,WdS(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())
N(RJRt_BaseCookie__parse_stringRR(R<trawdataR7R8((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyR]s
cC`sVd}t|�}d}x7d|ko2|knrQ|j||�}|sSPn|jd�|jd�}}|jd�}|ddkr�|rN|||d<qNq|j�tjkr
|rN|dkr�|j�tjkrt ||<qq
t
|�||<qNq|dk r|j|�\} }
|j|| |
�||}qqWdS(Niukeyuvalu$i(
RR6RtgrouptendR>R5R:RVtTrueR$RZRb(R<RtpattRRR`tmatchR7R8RcRd((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyt__parse_string&s,N(RRRURZR\R6R=RbR;RIRXR RNRPR]t_CookiePatternRi(((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyRY�s tSimpleCookiecB`s
eZdZd�Zd�ZRS(u�
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.
cC`st|�|fS(N(R$(R<RC((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyRZQscC`st|�}|t|�fS(N(RR(R<RCR[((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyR\Ts(RRRURZR\(((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyRrJs (*RUt
__future__RRRRtfuture.builtinsRRRRtfuture.utilsRR tretASCIItstringt__all__ReRRSRgt ExceptionR
t
ascii_letterstdigitsRWRRtcompileRRR$t_weekdaynameR6t
_monthnameR4R5t_LegalCharsPattRqRYRr(((sA/usr/lib/python2.7/site-packages/future/backports/http/cookies.pyt<module>�s�"
2�t