ž ¦ÿf³(c@sœdZddddddddgZd d lZd d lZd d lZd d lZd d lZd d lZyd d l Z Wne k rœd d l Z YnXd d l Zd d lmZeZead d „ZeejjƒZdZdd„ZdZdd„ZdddddddgZdddddd d!d"d#d$d%d&g ZgZ x!eD]Z!e j"e!j#ƒƒqYWed'd(„Z$ed)d*„Z%ied+6ed,6ed-6ed.6Z&ej'd/ej(ƒZ)d0d1„Z*d2d3„Z+ej'd4ej(ƒZ,ej'd5ej-ej(BƒZ.ej'd6ej/ej(BƒZ0d7d8„Z1ej'd9ej/ej(BƒZ2d:d;„Z3d<d=„Z4ej'd>ƒZ5ej'd?ƒZ6ej'd@ƒZ7ej'dAƒZ8dBdC„Z9ej'dDƒZ:dEdF„Z;dGdH„Z<dIdJ„Z=ej'dKej(ƒZ>dLdM„Z?dNdO„Z@dPdQ„ZAdRdS„ZBej'dTej(ƒZCdUdV„ZDdWdX„ZEdYdZ„ZFd[d\„ZGd]ZHej'd^ƒZId_d`„ZJdadb„ZKdcdd„ZLdedf„ZMGdgd„dƒZNGdhd„dƒZOGdid„deOƒZPdjdk„ZQdldm„ZRGdndo„doƒZSGdpd„dƒZTGdqd„deUƒZVGdrd„deTƒZWdsdt„ZXGdud„deWƒZYGdvd„deWƒZZd S(wuªHTTP cookie handling for web clients. 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 uCookieu CookieJaru CookiePolicyuDefaultCookiePolicyu FileCookieJaru LWPCookieJaru LoadErroruMozillaCookieJariN(utimegmcGs;ts dSts.ddl}|jdƒantj|ŒS(Niuhttp.cookiejar(udebuguloggeruloggingu getLogger(uargsulogging((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu_debug.s  u_debuguQa filename was not supplied (nor was the CookieJar instance initialised with one)cCsgddl}ddl}ddl}|jƒ}|jd|ƒ|jƒ}|jd|ddƒdS(Niuhttp.cookiejar bug! %su stackleveli(uiouwarningsu tracebackuStringIOu print_excuNoneugetvalueuwarn(uiouwarningsu tracebackufumsg((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu_warn_unhandled_exception<s $  u_warn_unhandled_exceptioni²c CsÌ|dd…\}}}}}}|tkrÄd|koEdknrÄd|koadknrÄd|ko}dknrÄd|ko™dknrÄd|koµdknrÄt|ƒSdSdS( Niii iiii;i=(u EPOCH_YEARutimegmuNone(uttuyearumonthumdayuhouruminusec((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu_timegmKs "DT u_timegmuMonuTueuWeduThuuFriuSatuSunuJanuFebuMaruApruMayuJunuJuluAuguSepuOctuNovuDeccCs\|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( uNoneudatetimeuutcnowuutcfromtimestampuyearumonthudayuhouruminuteusecond(utudt((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu time2isozYs u time2isozcCsq|dkrtjjƒ}ntjj|ƒ}dt|jƒ|jt|jd|j |j |j |j fS(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( uNoneudatetimeuutcnowuutcfromtimestampuDAYSuweekdayudayuMONTHSumonthuyearuhouruminuteusecond(utudt((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu time2netscapels !u time2netscapeuGMTuUTCuUTuZu^([-+])?(\d\d?):?(\d\d)?$cCsžd}|tkrd}ntj|ƒ}|ršdt|jdƒƒ}|jdƒrx|dt|jdƒƒ}n|jdƒdkrš| }qšn|S(Niiiii<iu-(uNoneu UTC_ZONESu TIMEZONE_REusearchuintugroup(utzuoffsetum((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuoffset_from_tz_stringƒs    uoffset_from_tz_stringc Csytj|jƒƒd}Wndtk rƒyt|ƒ}Wntk rUdSYnXd|komdknr{|}ndSYnX|dkr™d}n|dkr®d}n|dkrÃd}nt|ƒ}t|ƒ}t|ƒ}t|ƒ}t|ƒ}|dkr‡tjtjƒƒd}|d} |} ||| }| | } t| ƒdkr‡| dkrw|d}q„|d}q‡nt |||||||fƒ} | dk rþ|dkrÉd}n|j ƒ}t |ƒ} | dkrñdS| | } n| S(Nii iièidi2uUTC( u MONTHS_LOWERuindexuloweru ValueErroruintuNoneutimeu localtimeuabsu_timegmuupperuoffset_from_tz_string( udayumonuyruhruminusecutzuimonucur_yrumutmputuoffset((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu _str2time‘sR                 !       u _str2timeuV^[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 Cs4tj|ƒ}|r’|jƒ}tj|djƒƒd}t|dƒ|t|dƒt|dƒt|dƒt|dƒf}t|ƒS|j ƒ}t j d|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(uSTRICT_DATE_REusearchugroupsu MONTHS_LOWERuindexuloweruintufloatu_timegmulstripu WEEKDAY_REusubuNoneuLOOSE_HTTP_DATE_REu _str2time( utextumugumonuttudayuyruhruminusecutz((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu http2timeÜs -  " $u http2timeuÆ^ (\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 Cs|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(ulstripuNoneu ISO_DATE_REusearchugroupsu _str2time( utextudayumonuyruhruminusecutzumu_((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuiso2time$s " 'uiso2timecCs7|jdƒ\}}|jd|…|j|d…S(u)Return unmatched part of re.Match object.iN(uspanustring(umatchustartuend((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu unmatchedEsu unmatchedu^\s*([^=\s;,]+)u&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"u^\s*=\s*([^\s;,]*)u\\(.)c Cs…g}xx|D]p}|}g}xE|rftj|ƒ}|røt|ƒ}|jdƒ}tj|ƒ}|rt|ƒ}|jdƒ}tjd|ƒ}nEtj|ƒ}|rÜt|ƒ}|jdƒ}|jƒ}nd}|j ||fƒq"|j ƒj dƒrB|j ƒdd…}|r9|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* 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,Nu^[=\s;]*u(uHEADER_TOKEN_REusearchu unmatchedugroupuHEADER_QUOTED_VALUE_REuHEADER_ESCAPE_REusubuHEADER_VALUE_REurstripuNoneuappendulstripu startswithureusubn( u header_valuesuresultutextu orig_textupairsumunameuvalueunon_junku nr_junk_chars((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyusplit_header_wordsNs>.       usplit_header_wordsu([\"\\])cCs½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(uNoneureusearchuHEADER_JOIN_ESCAPE_REusubuappendujoin(ulistsuheadersupairsuattrukuv((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyujoin_header_words¤s    ujoin_header_wordscCsH|jdƒr"|dd…}n|jdƒrD|dd…}n|S(Nu"iiÿÿÿÿ(u startswithuendswith(utext((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu strip_quotes½s u strip_quotesc Cshd}g}xU|D]M}g}d}x ttjd|ƒƒD]ò\}}|jƒ}|d krhq>nd |kr„|d}} n'tjd |d ƒ\}} |jƒ}|d kr|jƒ} | |krØ| }n|dkrùt| ƒ} d}n|dkrt t| ƒƒ} qn|j || fƒq>W|r|sP|j dƒ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-ageFNT(uversionu0( uFalseu enumerateureuspliturstripuNoneulstripuloweru strip_quotesuTrueu http2timeuappend( u ns_headersu known_attrsuresultu ns_headerupairsu version_setuiiuparamukuvulc((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuparse_ns_headersÄs: %            uparse_ns_headersu\.\d+$cCsKtj|ƒrdS|dkr#dS|ddksC|ddkrGdSdS(u*Return True if text is a host domain name.uiu.iFiÿÿÿÿT(uIPV4_REusearchuFalseuTrue(utext((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuis_HDNùs  uis_HDNcCs”|jƒ}|jƒ}||kr(dSt|ƒs8dS|j|ƒ}|dks_|dkrcdS|jdƒsvdSt|dd…ƒsdSdS(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. iiu.NTFiÿÿÿÿ(uloweruTrueuis_HDNuFalseurfindu startswith(uAuBui((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu domain_matchs    u domain_matchcCstj|ƒrdSdS(udReturn True if text is a sort-of-like a host domain name. For accepting/blocking domains. FT(uIPV4_REusearchuFalseuTrue(utext((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuliberal_is_HDN/suliberal_is_HDNcCs‡|jƒ}|jƒ}t|ƒo-t|ƒsD||kr@dSdS|jdƒ}|rl|j|ƒrldS| rƒ||krƒdSdS(u\For blocking/accepting domains. A and B may be host domain names or IP addresses. u.TF(uloweruliberal_is_HDNuTrueuFalseu startswithuendswith(uAuBu initial_dot((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuuser_domain_match9s   uuser_domain_matchu:\d+$cCsb|jƒ}tjj|ƒd}|dkrC|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(u get_full_urluurllibuparseuurlparseu get_headeru cut_port_reusubulower(urequestuurluhost((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu request_hostNs   u request_hostcCsLt|ƒ}}|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.iu.localiÿÿÿÿ(u request_hostufinduIPV4_REusearch(urequestuerhnureq_host((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyueff_request_host^s% ueff_request_hostcCsM|jƒ}tjj|ƒ}t|jƒ}|jdƒsId|}n|S(u6Path component of request-URI, as defined by RFC 2965.u/(u get_full_urluurllibuparseuurlsplitu escape_pathupathu startswith(urequestuurlupartsupath((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu request_pathis   u request_pathc Csy|j}|jdƒ}|dkro||dd…}yt|ƒWqutk rktd|ƒdSYquXnt}|S(Nu:iiunonnumeric port: '%s'(uhostufinduintu ValueErroru_debuguNoneuDEFAULT_HTTP_PORT(urequestuhostuiuport((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu request_portss     u request_portu%/;:@&=+$,!~*'()u%([0-9a-fA-F][0-9a-fA-F])cCsd|jdƒjƒS(Nu%%%si(ugroupuupper(umatch((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuuppercase_escaped_char…suuppercase_escaped_charcCs+tjj|tƒ}tjt|ƒ}|S(uEEscape any invalid characters in HTTP URL, and uppercase all escapes.(uurllibuparseuquoteuHTTP_PATH_SAFEuESCAPED_CHAR_REusubuuppercase_escaped_char(upath((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu escape_path‡s u escape_pathcCsq|jdƒ}|dkrm||dd…}|jdƒ}t|ƒrm|dksb|dkrmd|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.iiNulocal(ufinduis_HDN(uhuiub((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyureach•s $ ureachcCs0t|ƒ}t|t|jƒƒs(dSdSdS(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. NTF(u request_hostu domain_matchureachuorigin_req_hostuTrueuFalse(urequestureq_host((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuis_third_party¸s uis_third_partycBsw|EeZdZdZddd„Zdd„Zddd„Zdd „Z dd d „Z d d „Z dd„Z dS(uCookieuÐ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. cCs |dk rt|ƒ}n| dk r6t| ƒ} n|dkr]|dkr]tdƒ‚n||_||_||_||_||_|j ƒ|_ ||_ ||_ | |_ | |_| |_| |_| |_||_||_||_tj|ƒ|_dS(Nu-if port is None, port_specified must be falseT(uNoneuintuTrueu ValueErroruversionunameuvalueuportuport_specifiedulowerudomainudomain_specifiedudomain_initial_dotupathupath_specifiedusecureuexpiresudiscarducommentu comment_urlurfc2109ucopyu_rest(uselfuversionunameuvalueuportuport_specifiedudomainudomain_specifiedudomain_initial_dotupathupath_specifiedusecureuexpiresudiscarducommentu comment_urluresturfc2109((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu__init__Ûs.                 uCookie.__init__cCs ||jkS(N(u_rest(uselfuname((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuhas_nonstandard_attrsuCookie.has_nonstandard_attrcCs|jj||ƒS(N(u_restuget(uselfunameudefault((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuget_nonstandard_attrsuCookie.get_nonstandard_attrcCs||j|(uportuNoneudomainupathuvalueuname(uselfupulimitu namevalue((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu__str__s   uCookie.__str__cCsˆg}x:dD]2}t||ƒ}|jd|t|ƒfƒq W|jdt|jƒƒ|jdt|jƒƒddj|ƒ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(ugetattruappendurepru_resturfc2109ujoin(uselfuargsunameuattr((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu__repr__s !uCookie.__repr__NF( u__name__u __module__u __qualname__u__doc__uFalseu__init__uhas_nonstandard_attruNoneuget_nonstandard_attruset_nonstandard_attru is_expiredu__str__u__repr__(u __locals__((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuCookieÉs    cBsJ|EeZdZdZdd„Zdd„Zdd„Zdd „Zd S( u CookiePolicyu 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. cCs 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(uNotImplementedError(uselfucookieurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuset_ok4suCookiePolicy.set_okcCs tƒ‚dS(uAReturn true if (and only if) cookie should be returned to server.N(uNotImplementedError(uselfucookieurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu return_ok=suCookiePolicy.return_okcCsdS(uMReturn false if cookies should not be returned, given cookie domain. T(uTrue(uselfudomainurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyudomain_return_okAsuCookiePolicy.domain_return_okcCsdS(uKReturn false if cookies should not be returned, given cookie path. T(uTrue(uselfupathurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyupath_return_okFsuCookiePolicy.path_return_okN(u__name__u __module__u __qualname__u__doc__uset_oku return_okudomain_return_okupath_return_ok(u __locals__((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu CookiePolicy+s   cBst|EeZdZdZdZdZdZdZeeBZd4d4d5d6d4d6d6d5d6ed6d6dd„ Z dd „Z d d „Zd d „Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Z d0d1„Z!d2d3„Z"d4S(7uDefaultCookiePolicyuBImplements the standard rules for accepting and returning cookies.iiiic Cs©||_||_||_||_||_||_| |_| |_| |_| |_ |dk rxt |ƒ|_ n f|_ |dk rœt |ƒ}n||_ dS(uAConstructor arguments should be passed as keyword arguments only.N(unetscapeurfc2965urfc2109_as_netscapeu hide_cookie2u strict_domainustrict_rfc2965_unverifiableustrict_ns_unverifiableustrict_ns_domainustrict_ns_set_initial_dollarustrict_ns_set_pathuNoneutupleu_blocked_domainsu_allowed_domains( uselfublocked_domainsuallowed_domainsunetscapeurfc2965urfc2109_as_netscapeu hide_cookie2u strict_domainustrict_rfc2965_unverifiableustrict_ns_unverifiableustrict_ns_domainustrict_ns_set_initial_dollarustrict_ns_set_path((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu__init__Vs             uDefaultCookiePolicy.__init__cCs|jS(u4Return the sequence of blocked domains (as a tuple).(u_blocked_domains(uself((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyublocked_domainswsu#DefaultCookiePolicy.blocked_domainscCst|ƒ|_dS(u$Set the sequence of blocked domains.N(utupleu_blocked_domains(uselfublocked_domains((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuset_blocked_domainszsu'DefaultCookiePolicy.set_blocked_domainscCs+x$|jD]}t||ƒr dSq WdS(NTF(u_blocked_domainsuuser_domain_matchuTrueuFalse(uselfudomainublocked_domain((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu is_blocked~suDefaultCookiePolicy.is_blockedcCs|jS(u=Return None, or the sequence of allowed domains (as a tuple).(u_allowed_domains(uself((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuallowed_domains„su#DefaultCookiePolicy.allowed_domainscCs(|dk rt|ƒ}n||_dS(u-Set the sequence of allowed domains, or None.N(uNoneutupleu_allowed_domains(uselfuallowed_domains((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuset_allowed_domains‡s u'DefaultCookiePolicy.set_allowed_domainscCs>|jdkrdSx$|jD]}t||ƒrdSqWdS(NFT(u_allowed_domainsuNoneuFalseuuser_domain_matchuTrue(uselfudomainuallowed_domain((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuis_not_alloweds u"DefaultCookiePolicy.is_not_allowedcCsWtd|j|jƒx:d D]2}d|}t||ƒ}|||ƒsd SqWd S( 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 verifiabilityunameupathudomainuportFT(u_debugunameuvalueugetattruFalseuTrue(uselfucookieurequestunufn_nameufn((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuset_ok•s  uDefaultCookiePolicy.set_okcCs{|jdkr)td|j|jƒdS|jdkrP|j rPtdƒdS|jdkrw|j rwtdƒdSdS(Nu0 Set-Cookie2 without version attribute (%s=%s)iu$ RFC 2965 cookies are switched offu$ Netscape cookies are switched offFT( uversionuNoneu_debugunameuvalueuFalseurfc2965unetscapeuTrue(uselfucookieurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuset_ok_version¨s  u"DefaultCookiePolicy.set_ok_versioncCsh|jrdt|ƒrd|jdkr;|jr;tdƒdS|jdkrd|jrdtdƒdSndS(Niu> third-party RFC 2965 cookie during unverifiable transactionu> third-party Netscape cookie during unverifiable transactionFT(u unverifiableuis_third_partyuversionustrict_rfc2965_unverifiableu_debuguFalseustrict_ns_unverifiableuTrue(uselfucookieurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuset_ok_verifiability·s  u(DefaultCookiePolicy.set_ok_verifiabilitycCsB|jdkr>|jr>|jjdƒr>td|jƒdSdS(Niu$u' illegal name (starts with '$'): '%s'FT(uversionustrict_ns_set_initial_dollarunameu startswithu_debuguFalseuTrue(uselfucookieurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu set_ok_nameÃs uDefaultCookiePolicy.set_ok_namecCsm|jrit|ƒ}|jdks<|jdkri|jri|j|jƒ ritd|j|ƒdSndS(Niu7 path attribute %s is not a prefix of request path %sFT( upath_specifiedu request_pathuversionustrict_ns_set_pathu startswithupathu_debuguFalseuTrue(uselfucookieurequestureq_path((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu set_ok_pathÌs   uDefaultCookiePolicy.set_ok_pathc Csš|j|jƒr&td|jƒd"S|j|jƒrLtd|jƒd"S|jr–t|ƒ\}}|j}|jr!|jdƒdkr!|j dƒ}|j dd|ƒ}|dkr!||dd…}||d|…} | j ƒd#krt |ƒdkrtd|ƒd"Sq!n|j dƒrC|dd…} n|} | j dƒdk} | r‚|dkr‚td|ƒd"S|jdkrÜ|j|ƒ rÜ|j dƒ rÜd|j|ƒ rÜtd||ƒd"Sn|jdksû|j|j@r!t||ƒs!td ||ƒd"Sn|jdks@|j|j@r–|dt |ƒ …} | j dƒdkr“tj|ƒ r“td!| |ƒd"Sq–nd$S(%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 dotF(ucouacucomueduuorgunetugovumiluintuaeroubizucatucoopuinfoujobsumobiumuseumunameuproutravelueuT(u is_blockedudomainu_debuguFalseuis_not_allowedudomain_specifiedueff_request_hostu strict_domainucounturfindulowerulenu startswithufinduversionuendswithustrict_ns_domainuDomainRFC2965Matchu domain_matchuDomainStrictNoDotsuIPV4_REusearchuTrue( uselfucookieurequestureq_hostuerhnudomainuiujutlduslduundotted_domainu embedded_dotsu host_prefix((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu set_ok_domain×sf          u!DefaultCookiePolicy.set_ok_domainc Csµ|jr±t|ƒ}|dkr*d}n t|ƒ}xx|jjdƒD]J}yt|ƒWn#tk r‚td|ƒdSYnX||krIPqIqIWtd||jƒdSndS(Nu80u,u bad port %s (not numeric)u$ request port (%s) not found in %sFT( uport_specifiedu request_portuNoneustruportusplituintu ValueErroru_debuguFalseuTrue(uselfucookieurequestureq_portup((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu set_ok_ports"          uDefaultCookiePolicy.set_ok_portcCsWtd|j|jƒx:d D]2}d|}t||ƒ}|||ƒsd SqWd S( 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 verifiabilityusecureuexpiresuportudomainFT(u_debugunameuvalueugetattruFalseuTrue(uselfucookieurequestunufn_nameufn((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu return_ok's   uDefaultCookiePolicy.return_okcCsR|jdkr'|j r'tdƒdS|jdkrN|j rNtdƒdSdS(Niu$ RFC 2965 cookies are switched offu$ Netscape cookies are switched offFT(uversionurfc2965u_debuguFalseunetscapeuTrue(uselfucookieurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyureturn_ok_version9s  u%DefaultCookiePolicy.return_ok_versioncCsh|jrdt|ƒrd|jdkr;|jr;tdƒdS|jdkrd|jrdtdƒdSndS(Niu> third-party RFC 2965 cookie during unverifiable transactionu> third-party Netscape cookie during unverifiable transactionFT(u unverifiableuis_third_partyuversionustrict_rfc2965_unverifiableu_debuguFalseustrict_ns_unverifiableuTrue(uselfucookieurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyureturn_ok_verifiabilityBs  u+DefaultCookiePolicy.return_ok_verifiabilitycCs*|jr&|jdkr&tdƒdSdS(Nuhttpsu( secure cookie with non-secure requestFT(usecureutypeu_debuguFalseuTrue(uselfucookieurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyureturn_ok_secureNs u$DefaultCookiePolicy.return_ok_securecCs$|j|jƒr tdƒdSdS(Nu cookie expiredFT(u is_expiredu_nowu_debuguFalseuTrue(uselfucookieurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyureturn_ok_expiresTs u%DefaultCookiePolicy.return_ok_expirescCsu|jrqt|ƒ}|dkr*d}nxD|jjdƒD]}||kr=Pq=q=Wtd||jƒdSndS(Nu80u,u0 request port %s does not match cookie port %sFT(uportu request_portuNoneusplitu_debuguFalseuTrue(uselfucookieurequestureq_portup((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyureturn_ok_portZs      u"DefaultCookiePolicy.return_ok_portc CsÌt|ƒ\}}|j}|jdkr^|j|j@r^|j r^||kr^tdƒdS|jdkr‘t||ƒ r‘td||ƒdS|jdkrÈd|j |ƒ rÈtd||ƒdSdS(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 %sFT( ueff_request_hostudomainuversionustrict_ns_domainuDomainStrictNonDomainudomain_specifiedu_debuguFalseu domain_matchuendswithuTrue(uselfucookieurequestureq_hostuerhnudomain((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyureturn_ok_domainhs    # u$DefaultCookiePolicy.return_ok_domaincCs°t|ƒ\}}|jdƒs.d|}n|jdƒsJd|}n|j|ƒpe|j|ƒsldS|j|ƒrŒtd|ƒdS|j|ƒr¬td|ƒdSdS(Nu.u" domain %s is in user block-listu& domain %s is not in user allow-listFT(ueff_request_hostu startswithuendswithuFalseu is_blockedu_debuguis_not_alloweduTrue(uselfudomainurequestureq_hostuerhn((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyudomain_return_ok~s    u$DefaultCookiePolicy.domain_return_okcCs@td|ƒt|ƒ}|j|ƒs<td||ƒdSdS(Nu- checking cookie path=%su %s does not path-match %sFT(u_debugu request_pathu startswithuFalseuTrue(uselfupathurequestureq_path((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyupath_return_ok”s   u"DefaultCookiePolicy.path_return_okNTF(#u__name__u __module__u __qualname__u__doc__uDomainStrictNoDotsuDomainStrictNonDomainuDomainRFC2965Matchu DomainLiberalu DomainStrictuNoneuTrueuFalseu__init__ublocked_domainsuset_blocked_domainsu is_blockeduallowed_domainsuset_allowed_domainsuis_not_alloweduset_okuset_ok_versionuset_ok_verifiabilityu set_ok_nameu set_ok_pathu set_ok_domainu set_ok_portu return_okureturn_ok_versionureturn_ok_verifiabilityureturn_ok_secureureturn_ok_expiresureturn_ok_portureturn_ok_domainudomain_return_okupath_return_ok(u __locals__((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuDefaultCookiePolicyLsL          ;       cCs"t|jƒƒ}t|j|ƒS(N(usortedukeysumapuget(uadictukeys((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuvals_sorted_by_keysuvals_sorted_by_keyc cswt|ƒ}xd|D]\}d}y |jWntk r>Yn#Xd}xt|ƒD] }|VqRW|s|VqqWdS(uBIterates over nested mapping, depth-first, in sorted order by key.NFT(uvals_sorted_by_keyuFalseuitemsuAttributeErroruTrueu deepvalues(umappinguvaluesuobjusubobj((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu deepvalues¡s     u deepvaluescBs|EeZdZdS(uAbsentN(u__name__u __module__u __qualname__(u __locals__((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuAbsent´suAbsentcBs‚|EeZdZdZejdƒZejdƒZejdƒZejdƒZ ejdƒZ ejdej ƒZ d2dd „Zd d „Zd d „Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd2d2d2d$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Z d.d/„Z!d0d1„Z"d2S(3u CookieJaru”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+)cCs=|dkrtƒ}n||_tjƒ|_i|_dS(N(uNoneuDefaultCookiePolicyu_policyu _threadinguRLocku _cookies_locku_cookies(uselfupolicy((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu__init__Ås    uCookieJar.__init__cCs ||_dS(N(u_policy(uselfupolicy((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu set_policyÍsuCookieJar.set_policycCsÌ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( u_policyudomain_return_oku_debugu_cookiesukeysupath_return_okuvaluesu return_okuappend(uselfudomainurequestucookiesucookies_by_pathupathucookies_by_nameucookie((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu_cookies_for_domainÐs      uCookieJar._cookies_for_domaincCs=g}x0|jjƒD]}|j|j||ƒƒqW|S(u2Return a list of cookies to be returned to server.(u_cookiesukeysuextendu_cookies_for_domain(uselfurequestucookiesudomain((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu_cookies_for_requestâsuCookieJar._cookies_for_requestc CsÑ|jddd„ddƒd}g}x¢|D]š}|j}|smd}|dkrm|jd|ƒqmn|jd k r¸|jj|jƒr¸|dkr¸|j j d|jƒ}n |j}|jd krã|j|j ƒn|jd|j |fƒ|dkr/|j r)|jd |j ƒn|jjd ƒr„|j}|j rp|jd ƒrp|d d …}n|jd |ƒn|jd k 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). ukeycSs t|jƒS(N(ulenupath(ua((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuósu)CookieJar._cookie_attrs..ureverseiu $Version=%su\\\1u%s=%su $Path="%s"u.iNu $Domain="%s"u$Portu="%s"TF(usortuTrueuFalseuversionuappenduvalueuNoneu non_word_reusearchuquote_reusubunameupath_specifiedupathudomainu startswithudomain_initial_dotuportuport_specified( uselfucookiesu version_setuattrsucookieuversionuvalueudomainup((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu _cookie_attrsés>    !      uCookieJar._cookie_attrsc Cs tdƒ|jjƒzÕttjƒƒ|j_|_|j|ƒ}|j|ƒ}|r‹|j dƒs‹|j ddj |ƒƒq‹n|jj rë|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(u_debugu _cookies_lockuacquireuintutimeu_policyu_nowu_cookies_for_requestu _cookie_attrsu has_headeruadd_unredirected_headerujoinurfc2965u hide_cookie2uversionureleaseuclear_expired_cookies(uselfurequestucookiesuattrsucookie((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuadd_cookie_header$s$   uCookieJar.add_cookie_headercCs$g}d}d}x |D]}|d \}}d}d} i} i} x­|d d …D]›\} } | jƒ}||ksˆ||kr‘|} n| |kr²| d kr²d} n| | krÄqXn| dkrÿ| d krðtdƒd} Pn| jƒ} n| dkr6|rqXn| d kr6tdƒqXq6n| dkr”d}yt| ƒ} Wn#tk r}tdƒd} PYnXd} |j| } n| |ks¬| |kré| d krÜ| dkrÜtd| ƒd} Pn| | | .no_matching_rfc2965N(uinfouget_allu_policyurfc2965unetscapeu_cookies_from_attrs_setusplit_header_wordsu Exceptionu_warn_unhandled_exceptionuparse_ns_headersu_process_rfc2109_cookiesuNoneudomainupathunameufilteruextend( uselfuresponseurequestuheadersu rfc2965_hdrsuns_hdrsurfc2965unetscapeucookiesu ns_cookiesulookupucookieuno_matching_rfc2965((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu make_cookiessB           uCookieJar.make_cookiesc Csj|jjƒzHttjƒƒ|j_|_|jj||ƒrT|j|ƒnWd|jjƒXdS(u-Set a cookie if policy says it's OK to do so.N( u _cookies_lockuacquireuintutimeu_policyu_nowuset_oku set_cookieurelease(uselfucookieurequest((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuset_cookie_if_okMs  uCookieJar.set_cookie_if_okc Cs”|j}|jjƒzi|j|kr8i||ju, (uappendurepru __class__ujoin(uselfurucookie((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu__repr__»s uCookieJar.__repr__cCsDg}x!|D]}|jt|ƒƒq Wd|jdj|ƒfS(Nu<%s[%s]>u, (uappendustru __class__ujoin(uselfurucookie((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu__str__Às uCookieJar.__str__N(#u__name__u __module__u __qualname__u__doc__ureucompileu non_word_reuquote_reustrict_domain_reu domain_reudots_reuASCIIumagic_reuNoneu__init__u set_policyu_cookies_for_domainu_cookies_for_requestu _cookie_attrsuadd_cookie_headeru_normalized_cookie_tuplesu_cookie_from_cookie_tupleu_cookies_from_attrs_setu_process_rfc2109_cookiesu make_cookiesuset_cookie_if_oku set_cookieuextract_cookiesuclearuclear_session_cookiesuclear_expired_cookiesu__iter__u__len__u__repr__u__str__(u __locals__((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu CookieJar¶s8    ; ! a \ 6      cBs|EeZdZdS(u LoadErrorN(u__name__u __module__u __qualname__(u __locals__((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu LoadErrorÇscBsn|EeZdZdZd d d dd„Zd d d dd„Zd d d dd„Zd d d dd „Z d S( u FileCookieJaru6CookieJar that can be loaded from and saved to a file.c Cs^tj||ƒ|dk rBy |dWqBtdƒ‚YqBXn||_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(u CookieJaru__init__uNoneu ValueErrorufilenameuboolu delayload(uselfufilenameu delayloadupolicy((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu__init__Ìs   uFileCookieJar.__init__cCs tƒ‚dS(uSave cookies to a file.N(uNotImplementedError(uselfufilenameuignore_discarduignore_expires((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyusaveÛsuFileCookieJar.savec Csn|dkr6|jdk r'|j}q6ttƒ‚nt|ƒ}z|j||||ƒWd|jƒXdS(uLoad cookies from a file.N(uNoneufilenameu ValueErroruMISSING_FILENAME_TEXTuopenu _really_loaduclose(uselfufilenameuignore_discarduignore_expiresuf((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyuloadßs   uFileCookieJar.loadcCsµ|dkr6|jdk r'|j}q6ttƒ‚n|jjƒz]tj|jƒ}i|_y|j |||ƒWn$t t fk rž||_‚YnXWd|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( uNoneufilenameu ValueErroruMISSING_FILENAME_TEXTu _cookies_lockuacquireucopyudeepcopyu_cookiesuloadu LoadErroruIOErrorurelease(uselfufilenameuignore_discarduignore_expiresu old_state((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyurevertës      uFileCookieJar.revertNF( u__name__u __module__u __qualname__u__doc__uNoneuFalseu__init__usaveuloadurevert(u __locals__((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu FileCookieJarÉs  cCs³|j|jfd|jfd|jfg}|jd k rU|jd|jfƒn|jrn|jdƒn|jr‡|jdƒn|j r |jdƒn|j r¹|jdƒn|j rç|jdt t |j ƒƒfƒn|jr|jdƒn|jr"|jd |jfƒn|jrD|jd |jfƒnt|jjƒƒ}x.|D]&}|j|t|j|ƒfƒq`W|jd t|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(unameuvalueupathudomainuportuNoneuappendupath_specifieduport_specifiedudomain_initial_dotusecureuexpiresu time2isozufloatudiscarducommentu comment_urlusortedu_restukeysustruversionujoin_header_words(ucookieuhukeysuk((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyulwp_cookie_strs6          $ulwp_cookie_strcBsM|EeZdZdZd d dd„Zdd d dd„Zdd„Z dS( u LWPCookieJaruZ 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) cCs€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(utimeudiscardu is_expireduappendulwp_cookie_strujoin(uselfuignore_discarduignore_expiresunowurucookie((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyu as_lwp_str/s  uLWPCookieJar.as_lwp_strc Cs|dkr6|jdk r'|j}q6ttƒ‚nt|dƒ}z*|jdƒ|j|j||ƒƒWd|jƒXdS(Nuwu#LWP-Cookies-2.0 (uNoneufilenameu ValueErroruMISSING_FILENAME_TEXTuopenuwriteu as_lwp_struclose(uselfufilenameuignore_discarduignore_expiresuf((u3/opt/alt/python33/lib64/python3.3/http/cookiejar.pyusave?s   uLWPCookieJar.savecCs|jƒ}|jj|ƒs7d|}t|ƒ‚ntjƒ}d}d} d} yvxo|jƒ} | dkrwPn| j|ƒsŒq[n| t|ƒd…jƒ} xt| gƒD] } | d\} }i}i}x| D]}d||sª           "  5  8 !  U   4  '      # b!ÿR  ÿÿ= |