Spade
Mini Shell
| Directory:~$ /lib/python2.7/site-packages/future/backports/http/ |
| [Home] [System Details] [Kill Me] |
�
,�]c@`s�dZddlmZddlmZddlmZddlmZddlmZmZm Z m
Z
mZddlm
Z
mZdd d
ddd
ddgZddlZddlZddlZer�de_nddlZddlmZmZmZddlmZyddlZWnek
r?ddlZnXddlm Z
e!Z"e#a$d�Z%ee�Z&dZ'd�Z(dZ)d�Z*dddddddgZ+d
d!d"d#d$d%d&d'd(d)d*d+gZ,gZ-x!e,D]Z.e-j/e.j0��q�We#d,�Z1e#d-�Z2ie#d.6e#d/6e#d06e#d16Z3ej4d2ej�Z5d3�Z6d4�Z7ej4d5ej�Z8ej4d6ej9ejB�Z:ej4d7ej;ejB�Z<d8�Z=ej4d9ej;ejB�Z>d:�Z?d;�Z@ej4d<�ZAej4d=�ZBej4d>�ZCej4d?�ZDd@�ZEej4dA�ZFdB�ZGdC�ZHdD�ZIej4dEej�ZJdF�ZKdG�ZLdH�ZMdI�ZNej4dJej�ZOdK�ZPdL�ZQdM�ZRdN�ZSdOZTej4dP�ZUdQ�ZVdR�ZWdS�ZXdT�ZYdUeZfdV��YZ[dWeZfdX��YZ\dYe\fdZ��YZ]d[�Z^d\�Z_d]eZfd^��YZ`d_eZfd`��YZadaebfdb��YZcdceafdd��YZdde�Zedfedfdg��YZfdhedfdi��YZgdS(ju�HTTP
cookie handling for web clients.
This is a backport of the Py3.3 ``http.cookiejar`` module for
python-future.
This module has (now fairly distant) origins in Gisle Aas' Perl module
HTTP::Cookies, from the libwww-perl library.
Docstrings, comments and debug strings in this code refer to the
attributes of the HTTP cookie system as cookie-attributes, to distinguish
them clearly from Python attributes.
Class diagram (note that BSDDBCookieJar and the MSIE* classes are not
distributed with the Python standard library, but are available from
http://wwwsearch.sf.net/):
CookieJar____
/ \ \
FileCookieJar \ \
/ | \ \ \
MozillaCookieJar | LWPCookieJar \ \
| | \
| ---MSIEBase | \
| / | | \
| / MSIEDBCookieJar BSDDBCookieJar
|/
MSIECookieJar
i(tunicode_literals(tprint_function(tdivision(tabsolute_import(tfiltertinttmaptopentstr(t
as_native_strtPY2uCookieu CookieJaruCookiePolicyuDefaultCookiePolicyu
FileCookieJaruLWPCookieJaru LoadErroruMozillaCookieJarN(turlparseturlsplittquote(t HTTP_PORT(ttimegmcG`s;ts
dSts.ddl}|jd�antj|�S(Niuhttp.cookiejar(tdebugtloggertloggingt getLogger(targsR((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_debug:suQa
filename was not supplied (nor was the CookieJar instance initialised with
one)cC`sgddl}ddl}ddl}|j�}|jd|�|j�}|jd|dd�dS(Niuhttp.cookiejar
bug!
%st
stackleveli(tiotwarningst tracebacktStringIOt print_exctNonetgetvaluetwarn(RRRtftmsg((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_warn_unhandled_exceptionHs
$i�cC`s�|d
\}}}}}}|tkr�d|ko?dknr�d|ko[dknr�d|kowdknr�d|ko�dknr�d|ko�dknr�t|�SdSdS( Niiiiiii;i=(t
EPOCH_YEARRR(ttttyeartmonthtmdaythourtmintsec((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_timegmWs
DT
uMonuTueuWeduThuuFriuSatuSunuJanuFebuMaruApruMayuJunuJuluAuguSepuOctuNovuDeccC`s\|dkrtjj�}ntjj|�}d|j|j|j|j|j|j fS(uHReturn
a string representing time in seconds since epoch, t.
If the function is called without an argument, it will use the current
time.
The format of the returned string is like "YYYY-MM-DD
hh:mm:ssZ",
representing Universal Time (UTC, aka GMT). An example of this format
is:
1994-11-24 08:49:37Z
u%04d-%02d-%02d %02d:%02d:%02dZN(
RtdatetimetutcnowtutcfromtimestampR$R%tdayR'tminutetsecond(tttdt((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt time2isozes
cC`sq|dkrtjj�}ntjj|�}dt|j�|jt|jd|j |j
|j|jfS(u�Return a string representing time in seconds since epoch,
t.
If the function is called without an argument, it will use the current
time.
The format of the returned string is like this:
Wed, DD-Mon-YYYY HH:MM:SS GMT
u"%s %02d-%s-%04d %02d:%02d:%02d
GMTiN(
RR+R,R-tDAYStweekdayR.tMONTHSR%R$R'R/R0(R1R2((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt
time2netscapexs!uGMTuUTCuUTuZu^([-+])?(\d\d?):?(\d\d)?$cC`s�d}|tkrd}ntj|�}|r�dt|jd��}|jd�rx|dt|jd��}n|jd�dkr�|}q�n|S(Niiiii<iu-(Rt UTC_ZONEStTIMEZONE_REtsearchRtgroup(ttztoffsettm((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytoffset_from_tz_string�s
c
C`s�ytj|j��d}Wn_tk
r~yt|�}Wntk
rQdSXd|koidknrw|}qdSnX|dkr�d}n|dkr�d}n|dkr�d}nt|�}t|�}t|�}t|�}t|�}|dkr�tjtj��d}|d} |}
||| }| |
} t| �dkr�| dkrr|d}q|d}q�nt |||||||f�}|dk r�|dkr�d}n|j
�}t|�}|dkr�dS||}n|S(Niiii�idi2uUTC(tMONTHS_LOWERtindextlowert
ValueErrorRRttimet localtimetabsR*tupperR?(
R.tmontyrthrR(R)R<timontcur_yrR>ttmpR1R=((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt _str2time�sR
!
uV^[SMTWF][a-z][a-z], (\d\d)
([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d)
GMT$u+^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*u�^
(\d\d?) # day
(?:\s+|[-\/])
(\w+) # month
(?:\s+|[-\/])
(\d+) # year
(?:
(?:\s+|:) # separator before clock
(\d\d?):(\d\d) # hour:min
(?::(\d\d))? # optional seconds
)? # optional clock
\s*
([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
\s*
(?:\(\w+\))? # ASCII representation of timezone in parens.
\s*$cC`s4tj|�}|r�|j�}tj|dj��d}t|d�|t|d�t|d�t|d�t|d�f}t|�S|j �}t
jd|d�}d gd\}}}}}} }
t
j|�}|d k r|j�\}}}}}} }
nd St|||||| |
�S(
u�Returns time in seconds since epoch of time represented by a string.
Return value is an integer.
None is returned if the format of str is unrecognized, the time is
outside
the representable range, or the timezone string is not recognized. If
the
string contains no timezone, UTC is assumed.
The timezone in the string may be numerical (like "-0800" or
"+0100") or a
string timezone (like "UTC", "GMT", "BST"
or "EST"). Currently, only the
timezone strings equivalent to UTC (zero offset) are known to the
function.
The function loosely parses the following formats:
Wed, 09 Feb 1994 22:23:32 GMT -- HTTP format
Tuesday, 08-Feb-94 14:15:29 GMT -- old rfc850 HTTP format
Tuesday, 08-Feb-1994 14:15:29 GMT -- broken rfc850 HTTP format
09 Feb 1994 22:23:32 GMT -- HTTP format (no weekday)
08-Feb-94 14:15:29 GMT -- rfc850 format (no weekday)
08-Feb-1994 14:15:29 GMT -- broken rfc850 format (no
weekday)
The parser ignores leading and trailing whitespace. The time may be
absent.
If the year is given with only 2 digits, the function will select the
century that makes the year closest to the current date.
iiiiiiuiN(tSTRICT_DATE_RER:tgroupsR@RARBRtfloatR*tlstript
WEEKDAY_REtsubRtLOOSE_HTTP_DATE_RERN(ttextR>tgRHR#R.RIRJR(R)R<((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt http2time�s-
"$u�^
(\d{4}) # year
[-\/]?
(\d\d?) # numerical month
[-\/]?
(\d\d?) # day
(?:
(?:\s+|[-:Tt]) # separator before clock
(\d\d?):?(\d\d) # hour:min
(?::?(\d\d(?:\.\d*)?))? # optional seconds (and fractional)
)? # optional clock
\s*
([-+]?\d\d?:?(:?\d\d)?
|Z|z)? # timezone (Z is "zero meridian", i.e.
GMT)
\s*$c
C`s�|j�}dgd\}}}}}}}tj|�}|dk rp|j�\}}}}}}}} ndSt|||||||�S(uv
As for http2time, but parses the ISO 8601 formats:
1994-02-03 14:15:29 -0100 -- ISO 8601 format
1994-02-03 14:15:29 -- zone is optional
1994-02-03 -- only date
1994-02-03T14:15:29 -- Use T as separator
19940203T141529Z -- ISO 8601 compact format
19940203 -- only date
iN(RRRtISO_DATE_RER:RPRN(
RVR.RHRIRJR(R)R<R>t_((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytiso2time0s
"'cC`s+|jd�\}}|j|
|j|S(u)Return unmatched part of re.Match
object.i(tspantstring(tmatchtstarttend((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt unmatchedQsu^\s*([^=\s;,]+)u&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"u^\s*=\s*([^\s;,]*)u\\(.)c
C`sg}xr|D]j}|}g}x?|r`tj|�}|r�t|�}|jd�}tj|�}|r�t|�}|jd�}tjd|�}nEtj|�}|r�t|�}|jd�}|j�}nd}|j
||f�q"|j�jd�r<|j�d}|r3|j
|�ng}q"t
jdd|�\}} |}q"W|r
|j
|�q
q
W|S(umParse header values into a list of lists containing
key,value pairs.
The function knows how to deal with ",", ";" and
"=" as well as quoted
values after "=". A list of space separated tokens are
parsed as if they
were separated by ";".
If the header_values passed as argument contains multiple values, then
they
are treated as if they were a single value separated by comma
",".
This means that this function is useful for parsing header fields that
follow this syntax (BNF as from the HTTP/1.1 specification, but we
relax
the requirement for tokens).
headers = #header
header = (token | parameter) *( [";"] (token |
parameter))
token = 1*<any CHAR except CTLs or separators>
separators = "(" | ")" | "<"
| ">" | "@"
| "," | ";" | ":" |
"\" | <">
| "/" | "[" | "]" |
"?" | "="
| "{" | "}" | SP | HT
quoted-string = ( <"> *(qdtext | quoted-pair )
<"> )
qdtext = <any TEXT except <">>
quoted-pair = "\" CHAR
parameter = attribute "=" value
attribute = token
value = token | quoted-string
Each header is represented by a list of key/value pairs. The value for
a
simple token (not part of a parameter) is None. Syntactically
incorrect
headers will not necessarily be parsed as you would want.
This is easier to describe with some examples:
>>> split_header_words(['foo="bar";
port="80,81"; discard, bar=baz'])
[[('foo', 'bar'), ('port',
'80,81'), ('discard', None)], [('bar',
'baz')]]
>>> split_header_words(['text/html;
charset="iso-8859-1"'])
[[('text/html', None), ('charset',
'iso-8859-1')]]
>>> split_header_words([r'Basic
realm="\"foo\bar\""'])
[[('Basic', None), ('realm',
'"foobar"')]]
iu\1u,u^[=\s;]*uN(tHEADER_TOKEN_RER:RaR;tHEADER_QUOTED_VALUE_REtHEADER_ESCAPE_RERTtHEADER_VALUE_REtrstripRtappendRRt
startswithtretsubn(
t
header_valuestresultRVt orig_texttpairsR>tnametvaluetnon_junkt
nr_junk_chars((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytsplit_header_wordsZs>.
u([\"\\])cC`s�g}x�|D]�}g}xq|D]i\}}|dk r|tjd|�sitjd|�}d|}nd||f}n|j|�q
W|r
|jdj|��q
q
Wdj|�S(u�Do the inverse (almost) of
the conversion done by split_header_words.
Takes a list of lists of (key, value) pairs and produces a single
header
value. Attribute values are quoted if needed.
>>> join_header_words([[("text/plain", None),
("charset", "iso-8859/1")]])
'text/plain; charset="iso-8859/1"'
>>> join_header_words([[("text/plain", None)],
[("charset", "iso-8859/1")]])
'text/plain, charset="iso-8859/1"'
u^\w+$u\\\1u"%s"u%s=%su; u,
N(RRiR:tHEADER_JOIN_ESCAPE_RERTRgtjoin(tliststheadersRntattrtktv((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytjoin_header_words�s
cC`s<|jd�r|d}n|jd�r8|d
}n|S(Nu"ii����(Rhtendswith(RV((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytstrip_quotes�s
cC`shd}g}xU|D]M}g}t}xttjd|��D]�\}}|j�}|d krhq>nd
|kr�|d}} n'tjd|d�\}} |j�}|d
kr|j�}
|
|kr�|
}n|dkr�t| �} t }n|dkrt
t| ��} qn|j|| f�q>W|r|sP|jd�n|j|�qqW|S(u5Ad-hoc
parser for Netscape protocol cookie-attributes.
The old Netscape cookie format for Set-Cookie can for instance contain
an unquoted "," in the expires field, so we have to use this
ad-hoc
parser instead of split_header_words.
XXX This may not make the best possible effort to parse all the crap
that Netscape Cookie headers contain. Ronald Tschalar's
HTTPClient
parser is probably better, so could do worse than following that if
this ever gives any trouble.
Currently, this is also used for parsing RFC 2109 cookies.
uexpiresudomainupathusecureuversionuportumax-ageu;\s*uu=u\s*=\s*iiu0(uexpiresudomainupathusecureuversionuportumax-ageN(uversionu0(tFalset enumerateRitsplitRfRRRRBR}tTrueRXRg(t
ns_headerstknown_attrsRlt ns_headerRntversion_settiitparamRyRztlc((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytparse_ns_headers�s:
% u\.\d+$cC`sKtj|�rtS|dkr#tS|ddksC|ddkrGtStS(u*Return
True if text is a host domain
name.uiu.i����(tIPV4_RER:R~R�(RV((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytis_HDNs
cC`s�|j�}|j�}||kr(tSt|�s8tS|j|�}|dks_|dkrctS|jd�svtSt|d�s�tStS(u�Return
True if domain A domain-matches domain B, according to RFC 2965.
A and B may be host domain names or IP addresses.
RFC 2965, section 1:
Host names can be specified either as an IP address or a HDN string.
Sometimes we compare one host name with another. (Such comparisons
SHALL
be case-insensitive.) Host A's name domain-matches host B's
if
* their host name strings string-compare equal; or
* A is a HDN string and has the form NB, where N is a non-empty
name string, B has the form .B', and B' is a HDN
string. (So,
x.y.com domain-matches .Y.com but not Y.com.)
Note that domain-match is not a commutative operation: a.b.c.com
domain-matches .c.com, but not the reverse.
i����iu.i(RBR�R�R~trfindRh(tAtBti((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytdomain_matchscC`stj|�rtStS(udReturn
True if text is a sort-of-like a host domain name.
For accepting/blocking domains.
(R�R:R~R�(RV((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytliberal_is_HDN;scC`s�|j�}|j�}t|�o-t|�sD||kr@tStS|jd�}|rl|j|�rltS|r�||kr�tStS(u\For
blocking/accepting domains.
A and B may be host domain names or IP addresses.
u.(RBR�R�R~RhR|(R�R�tinitial_dot((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytuser_domain_matchEsu:\d+$cC`s\|j�}t|�d}|dkr=|jdd�}ntjd|d�}|j�S(u�Return
request-host, as defined by RFC 2965.
Variation from RFC: returned value is lowercased, for convenient
comparison.
iuuHost(tget_full_urlRt
get_headertcut_port_reRTRB(trequestturlthost((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytrequest_hostZscC`sLt|�}}|jd�dkrBtj|�rB|d}n||fS(uzReturn
a tuple (request-host, effective request-host name).
As defined by RFC 2965, except both are lowercased.
u.i����u.local(R�tfindR�R:(R�terhntreq_host((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyteff_request_hostjs%
cC`sG|j�}t|�}t|j�}|jd�sCd|}n|S(u6Path
component of request-URI, as defined by RFC
2965.u/(R�Rtescape_pathtpathRh(R�R�tpartsR�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytrequest_pathus
cC`so|j}|jd�}|dkre||d}yt|�Wqktk
ratd|�dSXnt}|S(Nu:iiunonnumeric port:
'%s'(R�R�RRCRRtDEFAULT_HTTP_PORT(R�R�R�tport((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytrequest_ports
u%/;:@&=+$,!~*'()u%([0-9a-fA-F][0-9a-fA-F])cC`sd|jd�j�S(Nu%%%si(R;RG(R^((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytuppercase_escaped_char�scC`s%t|t�}tjt|�}|S(uEEscape
any invalid characters in HTTP URL, and uppercase all
escapes.(R
tHTTP_PATH_SAFEtESCAPED_CHAR_RERTR�(R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR��s
cC`sk|jd�}|dkrg||d}|jd�}t|�rg|dks\|dkrgd|Sn|S(uBReturn
reach of host h, as defined by RFC 2965, section 1.
The reach R of a host name H is defined as follows:
* If
- H is the host domain name of a host; and,
- H has the form A.B; and
- A has no embedded (that is, interior) dots; and
- B has at least one embedded dot, or B is the string
"local".
then the reach of H is .B.
* Otherwise, the reach of H is H.
>>> reach("www.acme.com")
'.acme.com'
>>> reach("acme.com")
'acme.com'
>>> reach("acme.local")
'.local'
u.iiulocal(R�R�(thR�tb((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreach�s$cC`s3t|�}t|t|j���s+tStSdS(u�
RFC 2965, section 3.3.6:
An unverifiable transaction is to a third-party host if its
request-
host U does not domain-match the reach R of the request-host O in
the
origin transaction.
N(R�R�R�tget_origin_req_hostR�R~(R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytis_third_party�s
tCookiecB`s_eZdZed�Zd�Zdd�Zd�Zdd�Z d�Z
e�d��ZRS( u�HTTP Cookie.
This class represents both Netscape and RFC 2965 cookies.
This is deliberately a very simple class. It just holds attributes.
It's
possible to construct Cookie instances that don't comply with the
cookie
standards. CookieJar.make_cookies is the factory function for Cookie
objects -- it deals with cookie parsing, supplying defaults, and
normalising to the representation used in this class. CookiePolicy is
responsible for checking them to see whether they should be accepted
from
and returned to the server.
Note that the port may be present in the headers, but unspecified
("Port"
rather than"Port=80", for example); if this is the case, port
is None.
cC`s |dk rt|�}n|dk r6t|�}n|dkr]|tkr]td��n||_||_||_||_||_|j �|_
||_||_| |_
|
|_||_||_|
|_||_||_||_tj|�|_dS(Nu-if port is None,
port_specified must be
false(RRR�RCtversionRoRpR�tport_specifiedRBtdomaintdomain_specifiedtdomain_initial_dotR�tpath_specifiedtsecuretexpirestdiscardtcommenttcomment_urltrfc2109tcopyt_rest(tselfR�RoRpR�R�R�R�R�R�R�R�R�R�R�R�trestR�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt__init__�s.
cC`s
||jkS(N(R�(R�Ro((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pythas_nonstandard_attrscC`s|jj||�S(N(R�tget(R�Rotdefault((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytget_nonstandard_attrscC`s||j|<dS(N(R�(R�RoRp((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_nonstandard_attrscC`sA|dkrtj�}n|jdk r=|j|kr=tStS(N(RRDR�R�R~(R�tnow((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt
is_expireds
cC`sx|jdkrd}n
d|j}|j||j}|jdk rad|j|jf}n |j}d||fS(Nuu:u%s=%su<Cookie
%s for
%s>(R�RR�R�RpRo(R�tptlimitt namevalue((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt__str__s
cC`s�g}x^dD]V}t||�}t|t�r@t|�}n|jtd�|t|�f�q
W|jdt|j��|jdt|j��ddj|�S(Nuversionunameuvalueuportuport_specifiedudomainudomain_specifiedudomain_initial_dotupathupath_specifiedusecureuexpiresudiscarducommentucomment_urlu%s=%surest=%su
rfc2109=%su
Cookie(%s)u,
(uversionunameuvalueuportuport_specifiedudomainudomain_specifiedudomain_initial_dotupathupath_specifiedusecureuexpiresudiscarducommentucomment_url(tgetattrt
isinstanceRRgtreprR�R�Ru(R�RRoRx((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt__repr__(s
'N(
t__name__t
__module__t__doc__R~R�R�RR�R�R�R�R R�(((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR��s
tCookiePolicycB`s2eZdZd�Zd�Zd�Zd�ZRS(u Defines which
cookies get accepted from and returned to server.
May also modify cookies, though this is probably a bad idea.
The subclass DefaultCookiePolicy defines the standard rules for
Netscape
and RFC 2965 cookies -- override that if you want a customised policy.
cC`s
t��dS(u�Return true if (and only if) cookie should be
accepted from server.
Currently, pre-expired cookies never get this far -- the CookieJar
class deletes such cookies itself.
N(tNotImplementedError(R�tcookieR�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_okFscC`s
t��dS(uAReturn
true if (and only if) cookie should be returned to
server.N(R�(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt return_okOscC`stS(uMReturn
false if cookies should not be returned, given cookie domain.
(R�(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytdomain_return_okSscC`stS(uKReturn
false if cookies should not be returned, given cookie path.
(R�(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytpath_return_okXs(R�R�R�R�R�R�R�(((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR�=s
tDefaultCookiePolicyc
B`s#eZdZdZdZdZdZeeBZdde e
de
e
e e
ee
e
d�Zd�Zd�Z
d�Zd �Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z
d�Z!RS(uBImplements the standard rules for accepting and returning
cookies.iiiic
C`s�||_||_||_||_||_||_| |_|
|_||_||_ |dk rxt|�|_n d|_|dk r�t|�}n||_
dS(uAConstructor
arguments should be passed as keyword arguments
only.N((tnetscapetrfc2965trfc2109_as_netscapethide_cookie2t
strict_domaintstrict_rfc2965_unverifiabletstrict_ns_unverifiabletstrict_ns_domaintstrict_ns_set_initial_dollartstrict_ns_set_pathRttuplet_blocked_domainst_allowed_domains(
R�tblocked_domainstallowed_domainsR�R�R�R�R�R�R�R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR�hs
cC`s|jS(u4Return the sequence of
blocked domains (as a
tuple).(R�(R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR��scC`st|�|_dS(u$Set
the sequence of blocked
domains.N(R�R�(R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_blocked_domains�scC`s+x$|jD]}t||�r
tSq
WtS(N(R�R�R�R~(R�R�tblocked_domain((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt
is_blocked�scC`s|jS(u=Return None, or the sequence of
allowed domains (as a
tuple).(R�(R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR��scC`s(|dk rt|�}n||_dS(u-Set
the sequence of allowed domains, or
None.N(RR�R�(R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_allowed_domains�scC`s>|jdkrtSx$|jD]}t||�rtSqWtS(N(R�RR~R�R�(R�R�tallowed_domain((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytis_not_allowed�scC`sWtd|j|j�x:d D]2}d|}t||�}|||�stSqWtS(
u�
If you override .set_ok(), be sure to call this method. If it
returns
false, so should your subclass (assuming your subclass wants to be
more
strict about which cookies to accept).
u - checking cookie
%s=%suversionu
verifiabilityunameupathudomainuportuset_ok_(uversionu
verifiabilityunameupathudomainuport(RRoRpR�R~R�(R�R�R�tntfn_nametfn((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR��s
cC`s{|jdkr)td|j|j�tS|jdkrP|jrPtd�tS|jdkrw|jrwtd�tStS(Nu0
Set-Cookie2 without version attribute (%s=%s)iu$ RFC 2965 cookies are
switched offu$ Netscape cookies are switched
off( R�RRRoRpR~R�R�R�(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_ok_version�s
cC`sh|jrdt|�rd|jdkr;|jr;td�tS|jdkrd|jrdtd�tSntS(Niu>
third-party RFC 2965 cookie during unverifiable transactionu>
third-party Netscape cookie during unverifiable
transaction(tunverifiableR�R�R�RR~R�R�(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_ok_verifiability�s
cC`sB|jdkr>|jr>|jjd�r>td|j�tStS(Niu$u'
illegal name (starts with '$'):
'%s'(R�R�RoRhRR~R�(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_ok_name�s
cC`sm|jrit|�}|jdks<|jdkri|jri|j|j�ritd|j|�tSntS(Niu7
path attribute %s is not a prefix of request path
%s( R�R�R�R�RhR�RR~R�(R�R�R�treq_path((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_ok_path�s
c
C`s�|j|j�r&td|j�tS|j|j�rLtd|j�tS|jr�t|�\}}|j}|jr|jd�dkr|j d�}|j dd|�}|dkr||d}||d|!} | j
�d"krt|�dkrtd|�tSqn|jd�r4|d}
n|}
|
j
d�dk}|rs|dkrstd|�tS|jdkr�|j|�r�|jd�r�d|j|�r�td||�tSn|jdks�|j|j@rt||�std
||�tSn|jdks1|j|j@r�|t|�
}|j
d�dkr~tj|�r~td!||�tSq�ntS(#Nu"
domain %s is in user block-listu& domain %s is not in user
allow-listu.iiiucouacucomueduuorgunetugovumiluintuaeroubizucatucoopuinfoujobsumobiumuseumunameuproutravelueuu&
country-code second level domain %su.localu/ non-local domain %s
contains no embedded dotuO effective request-host %s (even with added
initial dot) does not end with %su5 effective request-host %s does not
domain-match %su. host prefix %s for domain %s contains a
dot(ucouacucomueduuorgunetugovumiluintuaeroubizucatucoopuinfoujobsumobiumuseumunameuproutravelueu(R�R�RR~R�R�R�R�tcountR�RBtlenRhR�R�R|R�tDomainRFC2965MatchR�tDomainStrictNoDotsR�R:R�(
R�R�R�R�R�R�R�tjttldtsldtundotted_domaint
embedded_dotsthost_prefix((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt
set_ok_domain�sf
cC`s�|jr�t|�}|dkr*d}nt|�}xt|jjd�D]F}yt|�Wntk
r~td|�t SX||krIPqIqIWtd||j�t Snt
S(Nu80u,u bad port %s (not numeric)u$ request port (%s) not found
in
%s(R�R�RRR�R�RRCRR~R�(R�R�R�treq_portR�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_ok_port$s"
cC`sWtd|j|j�x:d D]2}d|}t||�}|||�stSqWtS(
u�
If you override .return_ok(), be sure to call this method. If it
returns false, so should your subclass (assuming your subclass
wants to
be more strict about which cookies to return).
u - checking cookie
%s=%suversionu
verifiabilityusecureuexpiresuportudomainu
return_ok_(uversionu
verifiabilityusecureuexpiresuportudomain(RRoRpR�R~R�(R�R�R�R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR�9s
cC`sR|jdkr'|jr'td�tS|jdkrN|jrNtd�tStS(Niu$
RFC 2965 cookies are switched offu$ Netscape cookies are switched
off(R�R�RR~R�R�(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_versionKs
cC`sh|jrdt|�rd|jdkr;|jr;td�tS|jdkrd|jrdtd�tSntS(Niu>
third-party RFC 2965 cookie during unverifiable transactionu>
third-party Netscape cookie during unverifiable
transaction(R�R�R�R�RR~R�R�(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_verifiabilityTs
cC`s*|jr&|jdkr&td�tStS(Nuhttpsu( secure
cookie with non-secure
request(R�ttypeRR~R�(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_secure`s
cC`s$|j|j�r td�tStS(Nu cookie
expired(R�t_nowRR~R�(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_expiresfs
cC`su|jrqt|�}|dkr*d}nxD|jjd�D]}||kr=Pq=q=Wtd||j�tSntS(Nu80u,u0
request port %s does not match cookie port
%s(R�R�RR�RR~R�(R�R�R�RR�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_portls
c C`s�t|�\}}|j}|jdkr^|j|j@r^|jr^||kr^td�tS|jdkr�t||�r�td||�tS|jdkr�d|j |�r�td||�tSt
S(NiuQ cookie with unspecified domain does not string-compare equal to
request domainuQ effective request-host name %s does not domain-match RFC
2965 cookie domain %su.u; request-host %s does not match Netscape cookie
domain
%s(R�R�R�R�tDomainStrictNonDomainR�RR~R�R|R�(R�R�R�R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_domainzs
#
cC`s�t|�\}}|jd�s.d|}n|jd�sJd|}n|j|�pe|j|�sltS|j|�r�td|�tS|j|�r�td|�tStS(Nu.u"
domain %s is in user block-listu& domain %s is not in user
allow-list(R�RhR|R~R�RR�R�(R�R�R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR��s
cC`s@td|�t|�}|j|�s<td||�tStS(Nu-
checking cookie path=%su %s does not path-match
%s(RR�RhR~R�(R�R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR��s
N("R�R�R�R�RR�t
DomainLiberaltDomainStrictRR�R~R�R�R�R�R�R�R�R�R�R�R�R�RRR�RRRR
RR
R�R�(((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR�^sL
; cC`s"t|j��}t|j|�S(N(tsortedtkeysRR�(tadictR((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytvals_sorted_by_key�scc`svt|�}xc|D][}t}y|jWntk
r=n#Xt}xt|�D]}|VqQW|s|VqqWdS(uBIterates over nested
mapping, depth-first, in sorted order by
key.N(RR~titemstAttributeErrorR�t
deepvalues(tmappingtvaluestobjtsubobj((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR�s
tAbsentcB`seZRS((R�R�(((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR�st CookieJarcB`s@eZdZejd�Zejd�Zejd�Zejd�Zejd�Z ejdej
�Zdd�Z
d�Zd �Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdddd�Zd�Zd�Zd�Zd�Ze
�d��Z!d�Z"RS(u�Collection of HTTP cookies.
You may not need to know about this class: try
urllib.request.build_opener(HTTPCookieProcessor).open(url).
u\Wu([\"\\])u\.?[^.]*u[^.]*u^\.+u^\#LWP-Cookies-(\d+\.\d+)cC`s=|dkrt�}n||_tj�|_i|_dS(N(RR�t_policyt
_threadingtRLockt
_cookies_lockt_cookies(R�tpolicy((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR��s
cC`s
||_dS(N(R(R�R"((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt
set_policy�scC`s�g}|jj||�sgStd|�|j|}x�|j�D]~}|jj||�sgqFn||}xP|j�D]B}|jj||�s�td�q~ntd�|j|�q~WqFW|S(Nu!Checking
%s for cookies to returnu not returning cookieu it's a
match( RR�RR!RR�RR�Rg(R�R�R�tcookiestcookies_by_pathR�tcookies_by_nameR�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_cookies_for_domain�s
cC`s=g}x0|jj�D]}|j|j||��qW|S(u2Return a list of
cookies to be returned to
server.(R!RtextendR'(R�R�R$R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_cookies_for_request�sc C`s�|jdd�dt�t}g}x�|D]�}|j}|sjt}|dkrj|jd|�qjn|jdk r�|jj|j�r�|dkr�|j j
d|j�}n |j}|jdkr�|j|j�n|jd|j|f�|dkr,|jr&|jd|j
�n|jjd �r{|j}|jrg|jd �rg|d
}n|jd|�n|jdk r�d}|jr�|d
|j}n|j|�q�q,q,W|S(u�Return
a list of cookie-attributes to be returned to server.
like ['foo="bar"; $Path="/"', ...]
The $Version attribute is also added when appropriate (currently
only
once per request).
tkeycS`s
t|j�S(N(R�R�(ta((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt<lambda>streverseiu$Version=%su\\\1u%s=%su
$Path="%s"u.iu$Domain="%s"u$Portu="%s"N(tsortR�R~R�RgRpRtnon_word_reR:tquote_reRTRoR�R�R�RhR�R�R�( R�R$R�tattrsR�R�RpR�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt
_cookie_attrs�s>
!
cC`std�|jj�z�ttj��|j_|_|j|�}|j|�}|r�|j d�s�|j
ddj|��q�n|jjr�|jj
r�|j d�r�x4|D])}|jdkr�|j
dd�Pq�q�WnWd|jj�X|j�dS(u�Add correct Cookie: header
to request (urllib.request.Request object).
The Cookie2 header is also added unless policy.hide_cookie2 is
true.
uadd_cookie_headeruCookieu;
uCookie2iu$Version="1"N(RR tacquireRRDRR R)R2t
has_headertadd_unredirected_headerRuR�R�R�treleasetclear_expired_cookies(R�R�R$R1R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytadd_cookie_header6s$
c
C`sg}d}d}x|D]�}|d\}}t}t} i}
i}x�|dD]�\}}
|j�}||ks�||kr�|}n||kr�|
dkr�t}
n||
kr�qRn|dkr�|
dkr�td
�t} Pn|
j�}
n|dkr0|rqRn|
dkr0td�qRq0n|dkr�t}yt|
�}
Wn"tk
rvtd�t} PnXd}|j|
}
n||ks�||kr�|
dkr�|dkr�td|�t} Pn|
|
|<qR|
||<qRW| r�qn|j|||
|f�qW|S(uReturn list of tuples containing normalised cookie
information.
attrs_set is the list of lists of key,value pairs extracted from
the Set-Cookie or Set-Cookie2 headers.
Tuples are name, value, standard, rest, where name and value are
the
cookie name and value, standard is a dictionary containing the
standard
cookie-attributes (discard, secure, version, expires or max-age,
domain, path and port) and rest is a dictionary containing the rest
of
the cookie-attributes.
udiscardusecureuversionuexpiresumax-ageudomainupathuportucommentu
commenturliiu% missing value for domain attributeuM missing or invalid
value for expires attribute: treating as session cookieu? missing or
invalid (non-numeric) value for max-age attributeu! missing value for %s
attribute(udiscardusecure(uversionuexpiresumax-ageudomainupathuportucommentu
commenturlN(uportucommentu
commenturl( R~RBRR�RRRCR Rg(R�t attrs_sett
cookie_tuplest
boolean_attrstvalue_attrstcookie_attrsRoRptmax_age_sett
bad_cookietstandardR�RyRzR�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_normalized_cookie_tuplesWsl
cC`s�|\}}}}|jdt�}|jdt�}|jdt�} |jdt�}
|jdd�}|dk r�yt|�}Wq�tk
r�dSXn|jdt�}|jdt�}
|jdd�}|jd d�}|tk r|d
krt}t|�}nrt}t|�}|j d�}|dkrl|d
kr[||
}ql||d }nt
|�d
kr�d}n|tk }t}|r�t|jd��}n|tkr�t
|�\}}|}n|jd�s�d|}nt}| tk rE| dkr't|�} qKt}tjdd
| �} nd} |
tkrfd}
t}
nQ|
|jkr�y|j|||�Wntk
r�nXtd|||�dSt|||| ||||||||
|
|||�S(Nudomainupathuportuexpiresuversionusecureudiscarducommentu
commenturluu/i����iiu.u\s+u2Expiring cookie,
domain='%s', path='%s',
name='%s'(R�RRRRCR~R�R�R�R�R�tboolRhR�R�RiRTR tcleartKeyErrorRR�(R�ttupR�RoRpR@R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_cookie_from_cookie_tuple�s�
cC`sR|j|�}g}x6|D].}|j||�}|r|j|�qqW|S(N(RARFRg(R�R9R�R:R$RER�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_cookies_from_attrs_sets
cC`sst|jdd�}|dkr1|jj}nx;|D]3}|jdkr8t|_|rkd|_qkq8q8WdS(Nurfc2109_as_netscapeii(R�RRR�R�R�R�(R�R$t
rfc2109_as_nsR�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_process_rfc2109_cookiess
c
C`s�|j�}|jdg�}|jdg�}|jj}|jj}|rV|s�|rd|s�|rr|s�|r�|r�gSy|jt|�|�}Wntk
r�t�g}nX|r�|r�y|jt |�|�} Wntk
r t�g} nX|j
| �|rni}
x*|D]"}d|
|j|j
|jf<q*W|
d�}t|| �} n| r�|j| �q�n|S(uAReturn sequence of
Cookie objects extracted from response object.uSet-Cookie2u
Set-CookiecS`s"|j|j|jf}||kS(N(R�R�Ro(t ns_cookietlookupR*((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytno_matching_rfc2965UsN(tinfotget_allRR�R�RGRst ExceptionR!R�RIRR�R�RoRR((
R�tresponseR�Rwtrfc2965_hdrstns_hdrsR�R�R$t
ns_cookiesRKR�RL((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytmake_cookies)sB
cC`sj|jj�zHttj��|j_|_|jj||�rT|j|�nWd|jj�XdS(u-Set
a cookie if policy says it's OK to do so.N( R R3RRDRR R�t
set_cookieR6(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_cookie_if_ok_s
cC`s�|j}|jj�zi|j|kr8i||j<n||j}|j|krdi||j<n||j}|||j<Wd|jj�XdS(u?Set
a cookie, without checking whether or not it should be set.N(R!R
R3R�R�RoR6(R�R�tctc2tc3((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRUls
cC`s�td|j��|jj�zrttj��|j_|_xL|j||�D]8}|jj ||�rUtd|�|j
|�qUqUWWd|jj�XdS(uAExtract cookies from response, where
allowable given the request.uextract_cookies: %su setting cookie:
%sN(RRMR
R3RRDRR RTR�RUR6(R�RPR�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytextract_cookiesys
cC`s�|dk rH|dks$|dkr3td��n|j|||=nZ|dk r�|dkrotd��n|j||=n"|dk r�|j|=n i|_dS(u�Clear
some cookies.
Invoking this method without arguments will clear all cookies. If
given a single argument, only cookies belonging to that domain will
be
removed. If given two arguments, cookies belonging to the
specified
path within that domain are removed. If given three arguments,
then
the cookie with the specified name, path and domain is removed.
Raises KeyError if no matching cookie exists.
u8domain and path must be given to remove a cookie by nameu.domain
must be given to remove cookies by
pathN(RRCR!(R�R�R�Ro((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRC�s
cC`s_|jj�z=x6|D].}|jr|j|j|j|j�qqWWd|jj�XdS(u�Discard
all session cookies.
Note that the .save() method won't save session cookies
anyway, unless
you ask otherwise by passing a true ignore_discard argument.
N(R
R3R�RCR�R�RoR6(R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytclear_session_cookies�s
'cC`sq|jj�zOtj�}x<|D]4}|j|�r#|j|j|j|j�q#q#WWd|jj�XdS(u�Discard
all expired cookies.
You probably don't need to call this method: expired cookies
are never
sent back to the server (provided you're using
DefaultCookiePolicy),
this method is called by CookieJar itself every so often, and the
.save() method won't save expired cookies anyway (unless you
ask
otherwise by passing a true ignore_expires argument).
N( R
R3RDR�RCR�R�RoR6(R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR7�s
'cC`s
t|j�S(N(RR!(R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt__iter__�scC`s%d}x|D]}|d}q
W|S(u#Return
number of contained
cookies.ii((R�R�R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt__len__�s
cC`sDg}x!|D]}|jt|��q
Wd|jdj|�fS(Nu<%s[%s]>u,
(RgR�t __class__Ru(R�trR�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR��s
cC`sDg}x!|D]}|jt|��q
Wd|jdj|�fS(Nu<%s[%s]>u,
(RgRR^Ru(R�R_R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR��s
N(#R�R�R�RitcompileR/R0tstrict_domain_ret domain_retdots_retASCIItmagic_reRR�R#R'R)R2R8RARFRGRIRTRVRURZRCR[R7R\R]R R�R�(((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR�s8 ; ! a \ 6
t LoadErrorcB`seZRS((R�R�(((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRf�st
FileCookieJarcB`sVeZdZdedd�Zdeed�Zdeed�Zdeed�ZRS(u6CookieJar
that can be loaded from and saved to a
file.cC`s]tj||�|dk rAy|dWqAtd��qAXn||_t|�|_dS(u}
Cookies are NOT loaded from the named file until either the .load()
or
.revert() method is called.
uufilename must be
string-likeN(RR�RRCtfilenameRBt delayload(R�RhRiR"((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR��s cC`s
t��dS(uSave
cookies to a
file.N(R�(R�Rhtignore_discardtignore_expires((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytsave�scC`sn|dkr6|jdk r'|j}q6tt��nt|�}z|j||||�Wd|j�XdS(uLoad
cookies from a
file.N(RRhRCtMISSING_FILENAME_TEXTRt_really_loadtclose(R�RhRjRkR((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytload�scC`s�|dkr6|jdk r'|j}q6tt��n|jj�z\tj|j�}i|_y|j |||�Wn#t
tfk
r�||_�nXWd|jj�XdS(u�Clear all cookies and reload
cookies from a saved file.
Raises LoadError (or IOError) if reversion is not successful; the
object's state will not be altered if this happens.
N(
RRhRCRmR
R3R�tdeepcopyR!RpRftIOErrorR6(R�RhRjRkt old_state((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytrevert�s
N( R�R�R�RR~R�RlRpRt(((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRg�scC`s�|j|jfd|jfd|jfg}|jd
k rU|jd|jf�n|jrn|jd�n|jr�|jd�n|j r�|jd�n|j
r�|jd�n|jr�|jdtt
|j��f�n|jr|jd�n|jr"|jd
|jf�n|jrD|jd|jf�nt|jj��}x.|D]&}|j|t|j|�f�q`W|jdt|j�f�t|g�S(u�Return
string representation of Cookie in an the LWP cookie file format.
Actually, the format is extended a bit -- see module docstring.
upathudomainuportu path_specu port_specu
domain_dotusecureuexpiresudiscarducommentu
commenturluversionN(u path_specN(u port_specN(u
domain_dotN(usecureN(udiscardN(RoRpR�R�R�RRgR�R�R�R�R�R3RQR�R�R�RR�RRR�R{(R�R�RRy((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pytlwp_cookie_strs6
$tLWPCookieJarcB`s8eZdZeed�Zdeed�Zd�ZRS(uZ
The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
"Set-Cookie3" is the format used by the libwww-perl libary,
not known
to be compatible with any browser, but which is easy to read and
doesn't lose information about RFC 2965 cookies.
Additional methods
as_lwp_str(ignore_discard=True, ignore_expired=True)
cC`s�tj�}g}xW|D]O}|r5|jr5qn|rQ|j|�rQqn|jdt|��qWdj|dg�S(u�Return
cookies as a string of "\n"-separated "Set-Cookie3"
headers.
ignore_discard and ignore_expires: see docstring for
FileCookieJar.save
uSet-Cookie3: %su
u(RDR�R�RgRuRu(R�RjRkR�R_R�((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt
as_lwp_strBs
cC`s�|dkr6|jdk r'|j}q6tt��nt|d�}z*|jd�|j|j||��Wd|j�XdS(Nuwu#LWP-Cookies-2.0
(RRhRCRmRtwriteRwRo(R�RhRjRkR((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRlRs
cC`s|j�}|jj|�s7d|}t|��ntj�}d}d} d}
yjxc|j�}|dkrwPn|j|�s�q[n|t|�j�}xt|g�D]}|d\}
}i}i}x| D]}t ||<q�Wx�|dD]�\}}|dk r!|j�}nd}||
ks?|| krH|}n|| krv|dkrit}n|||<q�||
kr�|||<q�|||<q�W|j
}|d�}|d�}|dk r�t|�}n|dkr�t}n|d�}|jd�}t|d�|
||d �|d�|||d�|d
�|d�|d�|||d
�|d�|�}|r�|jr�q�n|r�|j|�r�q�n|j|�q�Wq[WnAtk
r��n.tk
rt�td||f��nXdS(Nu5%r does not look like a
Set-Cookie3 (LWP) format fileuSet-Cookie3:u port_specu path_specu
domain_dotusecureudiscarduversionuportupathudomainuexpiresucommentu
commenturluiiu.u&invalid Set-Cookie3 format file %r:
%r(u port_specu path_specu
domain_dotusecureudiscard(uversionuportupathudomainuexpiresucommentu
commenturl(treadlineReR:RfRDRhR�tstripRsR~RRBR�R�R[R�R�R�RURrROR!(R�RRhRjRktmagicR
R�theaderR;R<tlinetdataRoRpR@R�RyRzR�R�R�R�R�R�RW((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRnas�
N( R�R�R�R�RwRR~RlRn(((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRv5stMozillaCookieJarcB`s>eZdZejd�ZdZd�Zde e d�Z
RS(u�
WARNING: you may want to backup your browser's cookies file if you
use
this class to save cookies. I *think* it works, but there have been
bugs in the past!
This class differs from CookieJar only in the format it uses to save
and
load cookies to and from a file. This class uses the Mozilla/Netscape
`cookies.txt' format. lynx uses this file format, too.
Don't expect cookies saved while the browser is running to be
noticed by
the browser (in fact, Mozilla on unix will overwrite your saved cookies
if
you change them on disk while it's running; on Windows, you
probably can't
save at all while the browser is running).
Note that the Mozilla/Netscape format will downgrade RFC2965 cookies to
Netscape cookies on saving.
In particular, the cookie version and port number information is lost,
together with information about whether or not Path, Port and Discard
were
specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not
the
domain as set in the HTTP header started with a dot (yes, I'm
aware some
domains in Netscape files start with a dot and some don't -- trust
me, you
really don't want to know any more about this).
Note that though Mozilla and Netscape use the same format, they use
slightly different headers. The class saves cookies using the Netscape
header by default (Mozilla can cope with that).
u#( Netscape)? HTTP Cookie Fileu~# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This is a generated file! Do not edit.
cC`s�tj�}|j�}|jj|�sG|j�td|��nynxg|j�}|dkriPn|jd�r�|d
}n|j�jd�sM|j�dkr�qMn|j d�\}} }
}}}
}|dk}| dk} |
dkr |}
d}n|jd �}t}|dkr9d}t}nt
d
|
|dt|| ||
t|||ddi�}|r�|jr�qMn|r�|j|�r�qMn|j|�qMWnAtk
r��n.tk
r�t�td||f��nXdS(
Nu4%r does not look like a Netscape
format cookies fileuu
i����u#u$u uTRUEu.iu+invalid Netscape format cookies file %r:
%r(u#u$(RDRyReR:RoRfR|RzRhR�RR~R�R�R�R�RURrROR!(R�RRhRjRkR�R{R}R�R�R�R�R�RoRpR�R�RW((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRn�sb
$
cC`s�|dkr6|jdk r'|j}q6tt��nt|d�}z+|j|j�tj�}x|D]}|r�|jr�qkn|r�|j |�r�qkn|j
r�d}nd}|jjd�r�d}nd}|j
dk r�t|j
�} nd} |jdkr$d}
|j}n|j}
|j}|jdj|j||j|| |
|g�d�qkWWd|j�XdS(NuwuTRUEuFALSEu.uu u
(RRhRCRmRRxR|RDR�R�R�R�RhR�RRpRoRuR�Ro(R�RhRjRkRR�R�R�R�R�RoRp((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRls@
N(R�R�R�RiR`ReR|RnRR~Rl(((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR�s
B(hR�t
__future__RRRRtfuture.builtinsRRRRRtfuture.utilsR R
t__all__R�R+RiRdRDtfuture.backports.urllib.parseRRR
tfuture.backports.http.clientRt threadingRtImportErrortdummy_threadingtcalendarRR~RRRRR�RmR!R"R*R4R6R@R%RgRBR3R7R8R`R9R?RNROtIRStXRURXRYR[RaRbRcReRdRsRtR{R}R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�tobjectR�R�R�RRRRRrRfRgRuRvR(((sC/usr/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt<module>s�(
" 5 8 ! U 4 '
# h!�R ��= |