ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ A[c @`sdZddlmZddlmZddlmZddlmZddlmZmZm Z m Z m Z ddl m Z dd d d d d ddgZddlZddlZddlZde_ddlZddlmZmZmZddlmZyddlZWnek r0ddlZnXddlmZe Z!e"a#dZ$e eZ%dZ&dZ'dZ(dZ)dddddddgZ*d d!d"d#d$d%d&d'd(d)d*d+g Z+gZ,x!e+D]Z-e,j.e-j/qWe"d,Z0e"d-Z1ie"d.6e"d/6e"d06e"d16Z2ej3d2ejZ4d3Z5d4Z6ej3d5ejZ7ej3d6ej8ejBZ9ej3d7ej:ejBZ;d8Z<ej3d9ej:ejBZ=d:Z>d;Z?ej3d<Z@ej3d=ZAej3d>ZBej3d?ZCd@ZDej3dAZEdBZFdCZGdDZHej3dEejZIdFZJdGZKdHZLdIZMej3dJejZNdKZOdLZPdMZQdNZRdOZSej3dPZTdQZUdRZVdSZWdTZXdUeYfdVYZZdWeYfdXYZ[dYe[fdZYZ\d[Z]d\Z^d]eYfd^YZ_d_eYfd`YZ`daeafdbYZbdce`fddYZcdeZddfecfdgYZedhecfdiYZfdS(juHTTP 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_struCookieu CookieJaru CookiePolicyuDefaultCookiePolicyu FileCookieJaru LWPCookieJaru LoadErroruMozillaCookieJarN(turlparseturlsplittquote(t HTTP_PORT(ttimegmcG`s;ts dSts.ddl}|jdantj|S(Niuhttp.cookiejar(tdebugtloggertloggingt getLogger(targsR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_debug9s  uQa filename was not supplied (nor was the CookieJar instance initialised with one)cC`sgddl}ddl}ddl}|j}|jd||j}|jd|dddS(Niuhttp.cookiejar bug! %st stackleveli(tiotwarningst tracebacktStringIOt print_exctNonetgetvaluetwarn(RRRtftmsg((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_warn_unhandled_exceptionGs $  icC`s|d \}}}}}}|tkrd|ko?dknrd|ko[dknrd|kowdknrd|kodknrd|kodknrt|SdSdS( Niii iiii;i=(t EPOCH_YEARRR(ttttyeartmonthtmdaythourtmintsec((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_timegmVs 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((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt time2isozds cC`sq|dkrtjj}ntjj|}dt|j|jt|jd|j |j |j |j fS(uReturn 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.R/(R0R1((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt time2netscapews !uGMTuUTCuUTuZu^([-+])?(\d\d?):?(\d\d)?$cC`sd}|tkrd}ntj|}|rdt|jd}|jdrx|dt|jd}n|jddkr| }qn|S(Niiiii<iu-(Rt UTC_ZONESt TIMEZONE_REtsearchRtgroup(ttztoffsettm((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytoffset_from_tz_strings    c C`sytj|jd}Wn_tk r~yt|}Wntk rQdSXd|koidknrw|}qdSnX|dkrd}n|dkrd}n|dkrd}nt|}t|}t|}t|}t|}|dkrtjtjd}|d} |} ||| }| | } t| dkr| dkrr|d}q|d}qnt |||||||f} | dk r|dkrd}n|j }t |} | dkrdS| | } n| S(Nii iiidi2uUTC( t MONTHS_LOWERtindextlowert ValueErrorRRttimet localtimetabsR)tupperR>( R-tmontyrthrR'R(R;timontcur_yrR=ttmpR0R<((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt _str2timesR               !       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*$c C`s4tj|}|r|j}tj|djd}t|d|t|dt|dt|dt|df}t|S|j }t j d|d}d gd\}}}}}} } t j|}|d k r|j\}}}}}} } nd St|||||| | S( uReturns 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_RER9tgroupsR?R@RARtfloatR)tlstript WEEKDAY_REtsubRtLOOSE_HTTP_DATE_RERM( ttextR=tgRGR"R-RHRIR'R(R;((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt http2times -  " $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(RQRt ISO_DATE_RER9RORM( RUR-RGRHRIR'R(R;R=t_((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytiso2time/s " 'cC`s+|jd\}}|j| |j|S(u)Return unmatched part of re.Match object.i(tspantstring(tmatchtstarttend((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt unmatchedPsu^\s*([^=\s;,]+)u&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"u^\s*=\s*([^\s;,]*)u\\(.)c C`st|t stg}x|D]}|}g}xd|rtj|}|rt|}|jd}tj|}|rt|}|jd}tj d|}nEt j|}|rt|}|jd}|j }nd}|j ||fq8|jjdrR|jd}|rI|j |ng}q8tjdd|\}} | dkstd|||f|}q8W|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* separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <"> | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) qdtext = > 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;]*uiu&split_header_words bug: '%s', '%s', %sN(t isinstanceRtAssertionErrortHEADER_TOKEN_RER9R`R:tHEADER_QUOTED_VALUE_REtHEADER_ESCAPE_RERStHEADER_VALUE_REtrstripRtappendRQt startswithtretsubn( t header_valuestresultRUt orig_texttpairsR=tnametvaluetnon_junkt nr_junk_chars((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytsplit_header_wordsYsF-       u([\"\\])cC`sg}x|D]}g}xq|D]i\}}|dk r|tjd|sitjd|}d|}nd||f}n|j|q W|r |jdj|q q Wdj|S(uDo 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(RRjR9tHEADER_JOIN_ESCAPE_RERSRhtjoin(tliststheadersRotattrtktv((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytjoin_header_wordss    cC`s<|jdr|d}n|jdr8|d }n|S(Nu"ii(Ritendswith(RU((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt strip_quotess   c C`shd}g}xU|D]M}g}t}x ttjd|D]\}}|j}|d krhq>nd |kr|d}} n'tjd |d \}} |j}|d kr|j} | |kr| }n|dkrt| } t }n|dkrt t| } qn|j || fq>W|r|sP|j dn|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 enumerateRjtsplitRgRRQRAR~tTrueRWRh( t ns_headerst known_attrsRmt ns_headerRot version_settiitparamRzR{tlc((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytparse_ns_headerss: %            u\.\d+$cC`sKtj|rtS|dkr#tS|ddksC|ddkrGtStS(u*Return True if text is a host domain name.uiu.i(tIPV4_RER9RR(RU((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytis_HDNs  cC`s|j}|j}||kr(tSt|s8tS|j|}|dks_|dkrctS|jdsvtSt|dstStS(uReturn 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. iiu.i(RARRRtrfindRi(tAtBti((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt domain_matchs    cC`stj|rtStS(udReturn True if text is a sort-of-like a host domain name. For accepting/blocking domains. (RR9RR(RU((sP/opt/alt/python27/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||krtStS(u\For blocking/accepting domains. A and B may be host domain names or IP addresses. u.(RARRRRiR}(RRt initial_dot((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytuser_domain_matchDs   u:\d+$cC`s\|j}t|d}|dkr=|jdd}ntjd|d}|jS(uReturn request-host, as defined by RFC 2965. Variation from RFC: returned value is lowercased, for convenient comparison. iuuHost(t get_full_urlR t get_headert cut_port_reRSRA(trequestturlthost((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt request_hostYs   cC`sLt|}}|jddkrBtj| rB|d}n||fS(uzReturn a tuple (request-host, effective request-host name). As defined by RFC 2965, except both are lowercased. u.iu.local(RtfindRR9(Rterhntreq_host((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyteff_request_hostis% cC`sG|j}t|}t|j}|jdsCd|}n|S(u6Path component of request-URI, as defined by RFC 2965.u/(RR t escape_pathtpathRi(RRtpartsR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt request_pathts    cC`so|j}|jd}|dkre||d}yt|Wqktk ratd|dSXnt}|S(Nu:iiunonnumeric port: '%s'(RRRRBRRtDEFAULT_HTTP_PORT(RRRtport((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt request_port~s    u%/;:@&=+$,!~*'()u%([0-9a-fA-F][0-9a-fA-F])cC`sd|jdjS(Nu%%%si(R:RF(R]((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytuppercase_escaped_charscC`s%t|t}tjt|}|S(uEEscape any invalid characters in HTTP URL, and uppercase all escapes.(R tHTTP_PATH_SAFEtESCAPED_CHAR_RERSR(R((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs 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(RR(thRtb((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreachs $ cC`s3t|}t|t|js+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(RRRtget_origin_req_hostRR(RR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytis_third_partys tCookiecB`s_eZdZedZdZddZdZddZ dZ e dZ RS( uHTTP 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]tdn||_||_||_||_||_|j |_ ||_ ||_ | |_ | |_| |_| |_| |_||_||_||_tj||_dS(Nu-if port is None, port_specified must be false(RRRRBtversionRpRqRtport_specifiedRAtdomaintdomain_specifiedtdomain_initial_dotRtpath_specifiedtsecuretexpirestdiscardtcommentt comment_urltrfc2109tcopyt_rest(tselfRRpRqRRRRRRRRRRRRtrestR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt__init__s.                 cC`s ||jkS(N(R(RRp((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pythas_nonstandard_attrscC`s|jj||S(N(Rtget(RRptdefault((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytget_nonstandard_attrscC`s||j|(RRRRRqRp(Rtptlimitt namevalue((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt__str__s   cC`sg}x^dD]V}t||}t|tr@t|}n|jtd|t|fq W|jdt|j|jdt|jddj|S(Nuversionunameuvalueuportuport_specifiedudomainudomain_specifiedudomain_initial_dotupathupath_specifiedusecureuexpiresudiscarducommentu comment_urlu%s=%surest=%su rfc2109=%su Cookie(%s)u, (uversionunameuvalueuportuport_specifiedudomainudomain_specifiedudomain_initial_dotupathupath_specifiedusecureuexpiresudiscarducommentu comment_url(tgetattrRaRRhtreprRRRv(RRRpRy((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt__repr__'s 'N( t__name__t __module__t__doc__RRRRRRRRR R(((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs     t CookiePolicycB`s2eZdZdZdZdZdZRS(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 tdS(uReturn 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(RtcookieR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_okEscC`s tdS(uAReturn true if (and only if) cookie should be returned to server.N(R(RRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt return_okNscC`stS(uMReturn false if cookies should not be returned, given cookie domain. (R(RRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytdomain_return_okRscC`stS(uKReturn false if cookies should not be returned, given cookie path. (R(RRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytpath_return_okWs(RRRRRRR(((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR<s   tDefaultCookiePolicyc B`s#eZdZdZdZdZdZeeBZdde e de e e e ee e d Z dZ dZ dZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!RS(uBImplements the standard rules for accepting and returning cookies.iiiic C`s||_||_||_||_||_||_| |_| |_| |_| |_ |dk rxt ||_ n d|_ |dk rt |}n||_ dS(uAConstructor arguments should be passed as keyword arguments only.N((tnetscapetrfc2965trfc2109_as_netscapet hide_cookie2t strict_domaintstrict_rfc2965_unverifiabletstrict_ns_unverifiabletstrict_ns_domaintstrict_ns_set_initial_dollartstrict_ns_set_pathRttuplet_blocked_domainst_allowed_domains( Rtblocked_domainstallowed_domainsRRRRRRRRRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRgs             cC`s|jS(u4Return the sequence of blocked domains (as a tuple).(R(R((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRscC`st||_dS(u$Set the sequence of blocked domains.N(RR(RR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_blocked_domainsscC`s+x$|jD]}t||r tSq WtS(N(RRRR(RRtblocked_domain((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt is_blockedscC`s|jS(u=Return None, or the sequence of allowed domains (as a tuple).(R(R((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRscC`s(|dk rt|}n||_dS(u-Set the sequence of allowed domains, or None.N(RRR(RR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_allowed_domainss cC`s>|jdkrtSx$|jD]}t||rtSqWtS(N(RRRRR(RRtallowed_domain((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytis_not_alloweds cC`sltd|j|j|jd k s+tx:d D]2}d|}t||}|||s2tSq2WtS( 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_N(uversionu verifiabilityunameupathudomainuport(RRpRqRRbRRR(RRRtntfn_nametfn((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs  cC`s{|jdkr)td|j|jtS|jdkrP|j rPtdtS|jdkrw|j rwtdtStS(Nu0 Set-Cookie2 without version attribute (%s=%s)iu$ RFC 2965 cookies are switched offu$ Netscape cookies are switched off( RRRRpRqRRRR(RRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_ok_versions  cC`sh|jrdt|rd|jdkr;|jr;tdtS|jdkrd|jrdtdtSntS(Niu> third-party RFC 2965 cookie during unverifiable transactionu> third-party Netscape cookie during unverifiable transaction(t unverifiableRRRRRRR(RRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytset_ok_verifiabilitys  cC`sB|jdkr>|jr>|jjdr>td|jtStS(Niu$u' illegal name (starts with '$'): '%s'(RRRpRiRRR(RRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt set_ok_names cC`sm|jrit|}|jdks<|jdkri|jri|j|j ritd|j|tSntS(Niu7 path attribute %s is not a prefix of request path %s( RRRRRiRRRR(RRRtreq_path((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt set_ok_paths   c C`s|j|jr&td|jtS|j|jrLtd|jtS|jrt|\}}|j}|jr|jddkr|j d}|j dd|}|dkr||d}||d|!} | j d"krt |dkrtd|tSqn|j dr4|d} n|} | j ddk} | rs|dkrstd|tS|jdkr|j| r|j d rd|j| rtd||tSn|jdks|j|j@rt||std ||tSn|jdks1|j|j@r|t | } | j ddkr~tj| r~td!| |tSqntS(#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(RRRRRRRRtcountRRAtlenRiRRR}RtDomainRFC2965MatchRtDomainStrictNoDotsRR9R( RRRRRRRtjttldtsldtundotted_domaint embedded_dotst host_prefix((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt set_ok_domainsf           cC`s|jrt|}|dkr*d}n t|}xt|jjdD]F}yt|Wntk r~td|t SX||krIPqIqIWtd||jt Snt S(Nu80u,u bad port %s (not numeric)u$ request port (%s) not found in %s( RRRRRRRRBRRR(RRRtreq_portR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt set_ok_port#s"         cC`sWtd|j|jx: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(RRpRqRRR(RRRRRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR8s   cC`sR|jdkr'|j r'tdtS|jdkrN|j rNtdtStS(Niu$ RFC 2965 cookies are switched offu$ Netscape cookies are switched off(RRRRRR(RRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_versionJs  cC`sh|jrdt|rd|jdkr;|jr;tdtS|jdkrd|jrdtdtSntS(Niu> third-party RFC 2965 cookie during unverifiable transactionu> third-party Netscape cookie during unverifiable transaction(RRRRRRRR(RRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_verifiabilitySs  cC`s*|jr&|jdkr&tdtStS(Nuhttpsu( secure cookie with non-secure request(RttypeRRR(RRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_secure_s cC`s$|j|jr tdtStS(Nu cookie expired(Rt_nowRRR(RRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_expireses cC`su|jrqt|}|dkr*d}nxD|jjdD]}||kr=Pq=q=Wtd||jtSntS(Nu80u,u0 request port %s does not match cookie port %s(RRRRRRR(RRRRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_portks      cC`st|\}}|j}|jdkr^|j|j@r^|j r^||kr^tdtS|jdkrt|| rtd||tS|jdkrd|j | rtd||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( RRRRtDomainStrictNonDomainRRRRR}R(RRRRRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreturn_ok_domainys    # cC`st|\}}|jds.d|}n|jdsJd|}n|j|pe|j|sltS|j|rtd|tS|j|rtd|tStS(Nu.u" domain %s is in user block-listu& domain %s is not in user allow-list(RRiR}RRRRR(RRRRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs    cC`s@td|t|}|j|s<td||tStS(Nu- checking cookie path=%su %s does not path-match %s(RRRiRR(RRRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs   N("RRRRR Rt DomainLiberalt DomainStrictRRRRRRRRRRRRRRRRRRRRRR R R RR(((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyR]sL           ;       cC`s"t|j}t|j|S(N(tsortedtkeysRR(tadictR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytvals_sorted_by_keyscc`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(RRtitemstAttributeErrorRt deepvalues(tmappingtvaluestobjtsubobj((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs     tAbsentcB`seZRS((RR(((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRst CookieJarcB`s@eZdZejdZejdZejdZejdZejdZ ejdej Z ddZ dZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZddddZdZdZdZdZe dZ!dZ"RS(uCollection 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(RRt_policyt _threadingtRLockt _cookies_lockt_cookies(Rtpolicy((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs    cC`s ||_dS(N(R(RR"((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt set_policyscC`sg}|jj||sgStd||j|}x|jD]~}|jj||sgqFn||}xP|jD]B}|jj||stdq~ntd|j|q~WqFW|S(Nu!Checking %s for cookies to returnu not returning cookieu it's a match( RRRR!RRRRRh(RRRtcookiestcookies_by_pathRtcookies_by_nameR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_cookies_for_domains      cC`s=g}x0|jjD]}|j|j||qW|S(u2Return a list of cookies to be returned to server.(R!RtextendR'(RRR$R((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt_cookies_for_requestsc C`s|jdddtt}g}x|D]}|j}|sjt}|dkrj|jd|qjn|jdk r|jj|jr|dkr|j j d|j}n |j}|jdkr|j|j n|jd|j |f|dkr,|j r&|jd|j n|jjd r{|j}|j rg|jd rg|d }n|jd |n|jdk rd }|jr|d |j}n|j|qq,q,W|S(uReturn 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|jS(N(RR(ta((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytttreverseiu $Version=%su\\\1u%s=%su $Path="%s"u.iu $Domain="%s"u$Portu="%s"N(tsortRRRRhRqRt non_word_reR9tquote_reRSRpRRRRiRRR( RR$RtattrsRRRqRR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt _cookie_attrss>    !       cC`s td|jjzttj|j_|_|j|}|j|}|r|j ds|j ddj |qn|jj r|jj r|j d rx4|D])}|jdkr|j ddPqqWnWd|jjX|jdS(uAdd 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 tacquireRRCRR R)R3t has_headertadd_unredirected_headerRvRRRtreleasetclear_expired_cookies(RRR$R2R((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytadd_cookie_header5s$   cC`sg}d}d}x|D]}|d \}}t}t} i} i} x|d D]\} } | j}||ks||kr|} n| |kr| dkrt} n| | krqRn| dkr| dkrtd t} Pn| j} n| dkr0|rqRn| dkr0tdqRq0n| dkrt}yt| } Wn"tk rvtdt} PnXd} |j| } n| |ks| |kr| dkr| dkrtd| t} Pn| | | u, (RhRt __class__Rv(RtrR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs cC`sDg}x!|D]}|jt|q Wd|jdj|fS(Nu<%s[%s]>u, (RhRR_Rv(RR`R((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs N(#RRRRjtcompileR0R1tstrict_domain_ret domain_retdots_retASCIItmagic_reRRR#R'R)R3R9RBRGRHRJRURWRVR[RDR\R8R]R^R RR(((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs8     ; ! a \ 6     t LoadErrorcB`seZRS((RR(((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRgst FileCookieJarcB`sVeZdZdeddZdeedZdeedZdeedZRS(u6CookieJar that can be loaded from and saved to a file.cC`s]tj|||dk rAy |dWqAtdqAXn||_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(RRRRBtfilenameRCt delayload(RRiRjR"((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs   cC`s tdS(uSave cookies to a file.N(R(RRitignore_discardtignore_expires((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytsavescC`sn|dkr6|jdk r'|j}q6ttnt|}z|j||||Wd|jXdS(uLoad cookies from a file.N(RRiRBtMISSING_FILENAME_TEXTRt _really_loadtclose(RRiRkRlR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytloads   cC`s|dkr6|jdk r'|j}q6ttn|jjz\tj|j}i|_y|j |||Wn#t t fk r||_nXWd|jj XdS(uClear 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( RRiRBRnR R4RtdeepcopyR!RqRgtIOErrorR7(RRiRkRlt old_state((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytreverts      N( RRRRRRRmRqRu(((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRhs  cC`s|j|jfd|jfd|jfg}|jd k rU|jd|jfn|jrn|jdn|jr|jdn|j r|jdn|j r|jdn|j r|jdt t |j fn|jr|jdn|jr"|jd |jfn|jrD|jd |jfnt|jj}x.|D]&}|j|t|j|fq`W|jd t|jft|gS(uReturn 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(RpRqRRRRRhRRRRRR2RPRRRRRRRRR|(RRRRz((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pytlwp_cookie_strs6          $t LWPCookieJarcB`s8eZdZeedZdeedZdZRS(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`stj}g}xW|D]O}| r5|jr5qn| rQ|j|rQqn|jdt|qWdj|dgS(uReturn cookies as a string of "\n"-separated "Set-Cookie3" headers. ignore_discard and ignore_expires: see docstring for FileCookieJar.save uSet-Cookie3: %su u(RCRRRhRvRv(RRkRlRR`R((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyt as_lwp_strAs  cC`s|dkr6|jdk r'|j}q6ttnt|d}z*|jd|j|j||Wd|jXdS(Nuwu#LWP-Cookies-2.0 (RRiRBRnRtwriteRxRp(RRiRkRlR((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRmQs   cC`s|j}|jj|s7d|}t|ntj}d}d} d} ykxd|j} | dkrwPn| j|sq[n| t|j} xt| gD]} | d\} }i}i}x| D]}t ||eZdZejdZdZdZde e dZ 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`stj}|j}|jj|sG|jtd|nyxz|j}|dkriPn|jdr|d }n|jjd sM|jdkrqMn|j d\}} } } } } }| dk} | dk} | dkr |} d}n|jd }| |ks*t t }| dkrKd} t }ntd | |dt || || t | | |ddi}| r|jrqMn| r|j|rqMn|j|qMWWnAtk rn.tk r ttd ||fnXdS( Nu4%r does not look like a Netscape format cookies fileuu iu#u$u uTRUEu.iu+invalid Netscape format cookies file %r: %r(u#u$(RCRzRfR9RpRgR}R{RiRRRbRRRRRRVRsRPR (RRRiRkRlRR|R~RRRRRRpRqRRRX((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRosd       $           c C`s|dkr6|jdk r'|j}q6ttnt|d}z+|j|jtj}x|D]}| r|jrqkn| r|j |rqkn|j rd}nd}|j j drd}nd}|j dk rt|j } nd} |jdkr$d} |j} n|j} |j} |jdj|j ||j|| | | gdqkWWd|jXdS(NuwuTRUEuFALSEu.uu u (RRiRBRnRRyR}RCRRRRRiRRRqRpRvRRp( RRiRkRlRRRRRRRpRq((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRms@         N( RRRRjRaRfR}RoRRRm(((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyRs  B(gRt __future__RRRRtfuture.builtinsRRRRRt future.utilsR t__all__RR*RjReRCtfuture.backports.urllib.parseR R R tfuture.backports.http.clientR t threadingRt ImportErrortdummy_threadingtcalendarRRRRRRRRnR R!R)R3R5R?R$RhRAR2R6R7RaR8R>RMRNtIRRtXRTRWRXRZR`RcRdRfReRtRuR|R~RRRRRRRRRRRRRRRRRtobjectRRRRRRRRsRgRhRvRwR(((sP/opt/alt/python27/lib/python2.7/site-packages/future/backports/http/cookiejar.pyts(             "  5  8 !  U   4  '      # h!R  = |