usr/lib64/python2.7/cookielib.pyo000064400000152566147207562320012565 0ustar00 mfc @sdZddddddddd g Zd d lZd d lZd d lZd d lZd d lZyd d lZWne k rd d l ZnXd d l Z d d l m Z eZead Zee jZdZdZdZdZdddddddgZdddddddd d!d"d#d$g ZgZx!eD]ZejejqCWed%Z ed&Z!ied'6ed(6ed)6ed*6Z"ej#d+Z$d,Z%d-Z&ej#d.Z'ej#d/ej(Z)ej#d0ej*Z+d1Z,ej#d2ej*Z-d3Z.d4Z/ej#d5Z0ej#d6Z1ej#d7Z2ej#d8Z3d9Z4ej#d:Z5d;Z6d<Z7d=Z8ej#d>Z9d?Z:d@Z;dAZ<dBZ=ej#dCZ>dDZ?dEZ@dFZAdGZBdHZCej#dIZDdJZEdKZFdLZGdMZHdfdNYZIdfdOYZJdeJfdPYZKdQZLdRZMdSfdTYZNdfdUYZOdePfdVYZQdeOfdWYZRd dXlSmTZTmUZUd dYlVmWZWd S(ZsHTTP 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 tCookiet CookieJart CookiePolicytDefaultCookiePolicyt FileCookieJart LWPCookieJartlwp_cookie_strt LoadErrortMozillaCookieJariN(ttimegmcGs;ts dSts.ddl}|jdantj|S(Nit cookielib(tdebugtloggertloggingt getLogger(targsR ((s!/usr/lib64/python2.7/cookielib.pyt_debug+s  sQa filename was not supplied (nor was the CookieJar instance initialised with one)cCsgddl}ddl}ddl}|j}|jd||j}|jd|dddS(Niscookielib bug! %st stackleveli(twarningst tracebacktStringIOt print_exctNonetgetvaluetwarn(RRRtftmsg((s!/usr/lib64/python2.7/cookielib.pyt_warn_unhandled_exception9s $  ic Cs|d \}}}}}}|tkrd|ko?dknrd|ko[dknrd|kowdknrd|kodknrd|kodknrt|SdSdS( Niii iiii;i=(t EPOCH_YEARR R(ttttyeartmonthtmdaythourtmintsec((s!/usr/lib64/python2.7/cookielib.pyt_timegmHs DT tMontTuetWedtThutFritSattSuntJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDeccCsZ|dkrtj}ntj|d \}}}}}}d||||||fS(sHReturn 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 is%04d-%02d-%02d %02d:%02d:%02dZN(Rttimetgmtime(ttRtmonR R!R"R#((s!/usr/lib64/python2.7/cookielib.pyt time2isozVs %cCsl|dkrtj}ntj|d \}}}}}}}dt||t|d||||fS(sReturn 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 is"%s %02d-%s-%04d %02d:%02d:%02d GMTiN(RR8R9tDAYStMONTHS(R:RR;R R!R"R#twday((s!/usr/lib64/python2.7/cookielib.pyt time2netscapegs (tGMTtUTCtUTtZs^([-+])?(\d\d?):?(\d\d)?$cCsd}|tkrd}ntj|}|rdt|jd}|jdrx|dt|jd}n|jddkr| }qn|S(Niiiii<it-(Rt UTC_ZONESt TIMEZONE_REtsearchtinttgroup(ttztoffsettm((s!/usr/lib64/python2.7/cookielib.pytoffset_from_tz_string{s    c Csytj|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 iiidi2RB( t MONTHS_LOWERtindextlowert ValueErrorRIRR8t localtimetabsR$tupperRN( tdayR;tyrthrR"R#RKtimontcur_yrRMttmpR:RL((s!/usr/lib64/python2.7/cookielib.pyt _str2timesR               !       sV^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) (\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$s+^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*s^ (\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|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( sReturns 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. iiiiiitiN(tSTRICT_DATE_RERHtgroupsRORPRQRItfloatR$tlstript WEEKDAY_REtsubRtLOOSE_HTTP_DATE_RER\( ttextRMtgR;RRVRWRXR"R#RK((s!/usr/lib64/python2.7/cookielib.pyt http2times -  " $s^ (\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(sv 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(RaRt ISO_DATE_RERHR_R\( ReRVR;RWRXR"R#RKRMt_((s!/usr/lib64/python2.7/cookielib.pytiso2times " 'cCs+|jd\}}|j| |j|S(s)Return unmatched part of re.Match object.i(tspantstring(tmatchtstarttend((s!/usr/lib64/python2.7/cookielib.pyt unmatched=ss^\s*([^=\s;,]+)s&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"s^\s*=\s*([^\s;,]*)s\\(.)c Csg}xr|D]j}|}g}x?|r`tj|}|rt|}|jd}tj|}|rt|}|jd}tjd|}nEtj|}|rt|}|jd}|j}nd}|j ||fq"|j j dr<|j d}|r3|j |ng}q"t jdd|\}} |}q"W|r |j |q q W|S(smParse 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"')]] is\1t,s^[=\s;]*R]N(tHEADER_TOKEN_RERHRpRJtHEADER_QUOTED_VALUE_REtHEADER_ESCAPE_RERctHEADER_VALUE_REtrstripRtappendRat startswithtretsubn( t header_valuestresultRet orig_texttpairsRMtnametvaluetnon_junkt nr_junk_chars((s!/usr/lib64/python2.7/cookielib.pytsplit_header_wordsFs>.       s([\"\\])cCsg}x|D]}g}xq|D]i\}}|dk r|tjd|sitjd|}d|}nd||f}n|j|q W|r |jdj|q q Wdj|S(sDo 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"' s^\w+$s\\\1s"%s"s%s=%ss; s, N(RRyRHtHEADER_JOIN_ESCAPE_RERcRwtjoin(tliststheadersR~tattrtktv((s!/usr/lib64/python2.7/cookielib.pytjoin_header_wordss    cCs<|jdr|d}n|jdr8|d }n|S(Nt"ii(Rxtendswith(Re((s!/usr/lib64/python2.7/cookielib.pyt _strip_quotess   c Cshd}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(s5Ad-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. texpirestdomaintpathtsecuretversiontportsmax-ages;\s*R]t=s\s*=\s*iit0(sexpiressdomainspathssecuresversionsportsmax-ageN(sversionR( tFalset enumerateRytsplitRvRRaRQRtTrueRgRw( t ns_headerst known_attrsR|t ns_headerR~t version_settiitparamRRtlc((s!/usr/lib64/python2.7/cookielib.pytparse_ns_headerss: %            s\.\d+$cCsKtj|rtS|dkr#tS|ddksC|ddkrGtStS(s*Return True if text is a host domain name.R]it.i(tIPV4_RERHRR(Re((s!/usr/lib64/python2.7/cookielib.pytis_HDNs  cCs|j}|j}||kr(tSt|s8tS|j|}|dks_|dkrctS|jdsvtSt|dstStS(sReturn 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. iiRi(RQRRRtrfindRx(tAtBti((s!/usr/lib64/python2.7/cookielib.pyt domain_matchs    cCstj|rtStS(sdReturn True if text is a sort-of-like a host domain name. For accepting/blocking domains. (RRHRR(Re((s!/usr/lib64/python2.7/cookielib.pytliberal_is_HDN'scCs|j}|j}t|o-t|sD||kr@tStS|jd}|rl|j|rltS| r||krtStS(s\For blocking/accepting domains. A and B may be host domain names or IP addresses. R(RQRRRRxR(RRt initial_dot((s!/usr/lib64/python2.7/cookielib.pytuser_domain_match1s   s:\d+$cCs_|j}tj|d}|dkr@|jdd}ntjd|d}|jS(sReturn request-host, as defined by RFC 2965. Variation from RFC: returned value is lowercased, for convenient comparison. iR]tHost(t get_full_urlturlparset get_headert cut_port_reRcRQ(trequestturlthost((s!/usr/lib64/python2.7/cookielib.pyt request_hostFs   cCsLt|}}|jddkrBtj| rB|d}n||fS(szReturn a tuple (request-host, effective request-host name). As defined by RFC 2965, except both are lowercased. Ris.local(RtfindRRH(Rterhntreq_host((s!/usr/lib64/python2.7/cookielib.pyteff_request_hostVs% cCsJ|j}tj|}t|j}|jdsFd|}n|S(s6Path component of request-URI, as defined by RFC 2965.t/(RRturlsplitt escape_pathRRx(RRtpartsR((s!/usr/lib64/python2.7/cookielib.pyt request_pathas   cCsr|j}|jd}|dkrh||d}yt|Wqntk rdtd|dSXnt}|S(Nt:iisnonnumeric port: '%s'(tget_hostRRIRRRRtDEFAULT_HTTP_PORT(RRRR((s!/usr/lib64/python2.7/cookielib.pyt request_portks    s%/;:@&=+$,!~*'()s%([0-9a-fA-F][0-9a-fA-F])cCsd|jdjS(Ns%%%si(RJRU(Rm((s!/usr/lib64/python2.7/cookielib.pytuppercase_escaped_char}scCsIt|tr!|jd}ntj|t}tjt|}|S(sEEscape any invalid characters in HTTP URL, and uppercase all escapes.sutf-8( t isinstancetunicodetencodeturllibtquotetHTTP_PATH_SAFEtESCAPED_CHAR_RERcR(R((s!/usr/lib64/python2.7/cookielib.pyRs cCsk|jd}|dkrg||d}|jd}t|rg|dks\|dkrgd|Sn|S(sBReturn 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' Riitlocal(RR(thRtb((s!/usr/lib64/python2.7/cookielib.pytreachs $ cCs3t|}t|t|js+tStSdS(s 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((s!/usr/lib64/python2.7/cookielib.pytis_third_partys cBsVeZdZedZdZddZdZddZ dZ dZ RS( sHTTP 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]|tkr]tdn||_||_||_||_||_|j |_ ||_ ||_ | |_ | |_| |_| |_| |_||_||_||_tj||_dS(Ns-if port is None, port_specified must be false(RRIRRRRRRRtport_specifiedRQRtdomain_specifiedtdomain_initial_dotRtpath_specifiedRRtdiscardtcommentt comment_urltrfc2109tcopyt_rest(tselfRRRRRRRRRRRRRRRtrestR((s!/usr/lib64/python2.7/cookielib.pyt__init__s.                 cCs ||jkS(N(R(RR((s!/usr/lib64/python2.7/cookielib.pythas_nonstandard_attrscCs|jj||S(N(Rtget(RRtdefault((s!/usr/lib64/python2.7/cookielib.pytget_nonstandard_attrscCs||j|(RRRRRR(Rtptlimitt namevalue((s!/usr/lib64/python2.7/cookielib.pyt__str__ s   cCsg}x:dD]2}t||}|jd|t|fq W|jdt|j|jdt|jddj|S(NRRRRRRRRRRRRRRRs%s=%ssrest=%ss rfc2109=%ss Cookie(%s)s, (sversionsnamesvaluesportsport_specifiedsdomainsdomain_specifiedsdomain_initial_dotspathspath_specifiedssecuresexpiressdiscardscomments comment_url(tgetattrRwtreprRRR(RRRR((s!/usr/lib64/python2.7/cookielib.pyt__repr__s !N( t__name__t __module__t__doc__RRRRRRRRR(((s!/usr/lib64/python2.7/cookielib.pyRs     cBs2eZdZdZdZdZdZRS(s 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 tdS(sReturn 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((s!/usr/lib64/python2.7/cookielib.pytset_ok.scCs tdS(sAReturn true if (and only if) cookie should be returned to server.N(R(RRR((s!/usr/lib64/python2.7/cookielib.pyt return_ok7scCstS(sMReturn false if cookies should not be returned, given cookie domain. (R(RRR((s!/usr/lib64/python2.7/cookielib.pytdomain_return_ok;scCstS(sKReturn false if cookies should not be returned, given cookie path. (R(RRR((s!/usr/lib64/python2.7/cookielib.pytpath_return_ok@s(RRRRRRR(((s!/usr/lib64/python2.7/cookielib.pyR%s   c Bs#eZdZdZdZdZdZeeBZdde e de e e e ee e d Z dZ dZ dZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!RS(sBImplements the standard rules for accepting and returning cookies.iiiic Cs||_||_||_||_||_||_| |_| |_| |_| |_ |dk rxt ||_ n d|_ |dk rt |}n||_ dS(sAConstructor 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((s!/usr/lib64/python2.7/cookielib.pyRPs             cCs|jS(s4Return the sequence of blocked domains (as a tuple).(R(R((s!/usr/lib64/python2.7/cookielib.pyRqscCst||_dS(s$Set the sequence of blocked domains.N(RR(RR((s!/usr/lib64/python2.7/cookielib.pytset_blocked_domainstscCs+x$|jD]}t||r tSq WtS(N(RRRR(RRtblocked_domain((s!/usr/lib64/python2.7/cookielib.pyt is_blockedxscCs|jS(s=Return None, or the sequence of allowed domains (as a tuple).(R(R((s!/usr/lib64/python2.7/cookielib.pyR~scCs(|dk rt|}n||_dS(s-Set the sequence of allowed domains, or None.N(RRR(RR((s!/usr/lib64/python2.7/cookielib.pytset_allowed_domainss cCs>|jdkrtSx$|jD]}t||rtSqWtS(N(RRRRR(RRtallowed_domain((s!/usr/lib64/python2.7/cookielib.pytis_not_alloweds cCsWtd|j|jx:d D]2}d|}t||}|||stSqWtS( s 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). s - checking cookie %s=%sRt verifiabilityRRRRtset_ok_(sversionR snamespathsdomainsport(RRRRRR(RRRtntfn_nametfn((s!/usr/lib64/python2.7/cookielib.pyRs  cCs{|jdkr)td|j|jtS|jdkrP|j rPtdtS|jdkrw|j rwtdtStS(Ns0 Set-Cookie2 without version attribute (%s=%s)is$ RFC 2965 cookies are switched offs$ Netscape cookies are switched off( RRRRRRRRR(RRR((s!/usr/lib64/python2.7/cookielib.pytset_ok_versions  cCsk|jrgt|rg|jdkr>|jr>tdtS|jdkrg|jrgtdtSntS(Nis> third-party RFC 2965 cookie during unverifiable transactions> third-party Netscape cookie during unverifiable transaction(tis_unverifiableRRRRRRR(RRR((s!/usr/lib64/python2.7/cookielib.pytset_ok_verifiabilitys  cCsB|jdkr>|jr>|jjdr>td|jtStS(Nit$s' illegal name (starts with '$'): '%s'(RRRRxRRR(RRR((s!/usr/lib64/python2.7/cookielib.pyt set_ok_names cCsm|jrit|}|jdks<|jdkri|jri|j|j ritd|j|tSntS(Nis7 path attribute %s is not a prefix of request path %s( RRRRRxRRRR(RRRtreq_path((s!/usr/lib64/python2.7/cookielib.pyt set_ok_paths   c Cs|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(#Ns" domain %s is in user block-lists& domain %s is not in user allow-listRiiitcotactcomtedutorgtnettgovtmilRItaerotbiztcattcooptinfotjobstmobitmuseumRtprottravelteus& country-code second level domain %ss.locals/ non-local domain %s contains no embedded dotsO effective request-host %s (even with added initial dot) does not end with %ss5 effective request-host %s does not domain-match %ss. host prefix %s for domain %s contains a dot(scoRRRRRRRsintRR scatR"sinfoR$R%R&snameR'R(R)(RRRRR RRRtcountRRQtlenRxRRRRtDomainRFC2965MatchRtDomainStrictNoDotsRRHR( RRRRRRRtjttldtsldtundotted_domaint embedded_dotst host_prefix((s!/usr/lib64/python2.7/cookielib.pyt set_ok_domainsf           cCs|jrt|}|dkr*d}n t|}xt|jjdD]F}yt|Wntk r~td|t SX||krIPqIqIWtd||jt Snt S(Nt80Rqs bad port %s (not numeric)s$ request port (%s) not found in %s( RRRtstrRRRIRRRRR(RRRtreq_portR((s!/usr/lib64/python2.7/cookielib.pyt set_ok_port s"         cCsWtd|j|jx:d D]2}d|}t||}|||stSqWtS( s 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). s - checking cookie %s=%sRR RRRRt return_ok_(sversions verifiabilityssecuresexpiressportsdomain(RRRRRR(RRRR RR((s!/usr/lib64/python2.7/cookielib.pyR!s   cCsR|jdkr'|j r'tdtS|jdkrN|j rNtdtStS(Nis$ RFC 2965 cookies are switched offs$ Netscape cookies are switched off(RRRRRR(RRR((s!/usr/lib64/python2.7/cookielib.pytreturn_ok_version3s  cCsk|jrgt|rg|jdkr>|jr>tdtS|jdkrg|jrgtdtSntS(Nis> third-party RFC 2965 cookie during unverifiable transactions> third-party Netscape cookie during unverifiable transaction(RRRRRRRR(RRR((s!/usr/lib64/python2.7/cookielib.pytreturn_ok_verifiability<s  cCs-|jr)|jdkr)tdtStS(Nthttpss( secure cookie with non-secure request(Rtget_typeRRR(RRR((s!/usr/lib64/python2.7/cookielib.pytreturn_ok_secureHs cCs$|j|jr tdtStS(Ns cookie expired(Rt_nowRRR(RRR((s!/usr/lib64/python2.7/cookielib.pytreturn_ok_expiresNs cCsu|jrqt|}|dkr*d}nxD|jjdD]}||kr=Pq=q=Wtd||jtSntS(NR5Rqs0 request port %s does not match cookie port %s(RRRRRRR(RRRR7R((s!/usr/lib64/python2.7/cookielib.pytreturn_ok_portTs      c Cst|\}}|j}|r>|jd r>d|}n|}|jdkr|j|j@r|j r||krtdtS|jdkrt || rtd||tS|jdkrd|j | rtd||tSt S(NRisQ cookie with unspecified domain does not string-compare equal to request domainsQ effective request-host name %s does not domain-match RFC 2965 cookie domain %ss; request-host %s does not match Netscape cookie domain %s( RRRxRRtDomainStrictNonDomainRRRRRR(RRRRRRt dotdomain((s!/usr/lib64/python2.7/cookielib.pytreturn_ok_domainbs&    # cCst|\}}|jds.d|}n|jdsJd|}n|rm|jd rmd|}n|}|j|p|j|stS|j|rtd|tS|j|rtd|tStS(NRs" domain %s is in user block-lists& domain %s is not in user allow-list(RRxRRRRR R(RRRRRRC((s!/usr/lib64/python2.7/cookielib.pyR}s"     cCs@td|t|}|j|s<td||tStS(Ns- checking cookie path=%ss %s does not path-match %s(RRRxRR(RRRR((s!/usr/lib64/python2.7/cookielib.pyRs   N("RRRR-RBR,t DomainLiberalt DomainStrictRRRRRRRRRR RRRRRR4R8RR:R;R>R@RARDRR(((s!/usr/lib64/python2.7/cookielib.pyRFsL           ;       cCs&|j}|jt|j|S(N(tkeystsorttmapR(tadictRG((s!/usr/lib64/python2.7/cookielib.pytvals_sorted_by_keys  ccsvt|}xc|D][}t}y |jWntk r=n#Xt}xt|D] }|VqQW|s|VqqWdS(sBIterates over nested mapping, depth-first, in sorted order by key.N(RKRtitemstAttributeErrorRt deepvalues(tmappingtvaluestobjtsubobj((s!/usr/lib64/python2.7/cookielib.pyRNs     tAbsentcBseZRS((RR(((s!/usr/lib64/python2.7/cookielib.pyRSscBs(eZdZejdZejdZejdZejdZejdZ dZ ddZ dZ d Zd Zd Zd Zd ZdZdZdZdZdZdZdZddddZdZdZdZdZdZdZ RS(sCollection of HTTP cookies. You may not need to know about this class: try urllib2.build_opener(HTTPCookieProcessor).open(url). s\Ws([\"\\])s\.?[^.]*s[^.]*s^\.+s^\#LWP-Cookies-(\d+\.\d+)cCs=|dkrt}n||_tj|_i|_dS(N(RRt_policyt _threadingtRLockt _cookies_lockt_cookies(Rtpolicy((s!/usr/lib64/python2.7/cookielib.pyRs    cCs ||_dS(N(RT(RRY((s!/usr/lib64/python2.7/cookielib.pyt set_policyscCsg}|jj||sgStd||j|}x|jD]~}|jj||sgqFn||}xP|jD]B}|jj||stdq~ntd|j|q~WqFW|S(Ns!Checking %s for cookies to returns not returning cookies it's a match( RTRRRXRGRRPRRw(RRRtcookiestcookies_by_pathRtcookies_by_nameR((s!/usr/lib64/python2.7/cookielib.pyt_cookies_for_domains      cCs=g}x0|jjD]}|j|j||qW|S(s2Return a list of cookies to be returned to server.(RXRGtextendR^(RRR[R((s!/usr/lib64/python2.7/cookielib.pyt_cookies_for_requestsc Cs|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(sReturn 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). tkeycSs t|jS(N(R+R(targ((s!/usr/lib64/python2.7/cookielib.pytstreverseis $Version=%ss\\\1s%s=%ss $Path="%s"Ris $Domain="%s"s$Ports="%s"N(RHRRRRwRRt non_word_reRHtquote_reRcRRRRRxRRR( RR[RtattrsRRRRR((s!/usr/lib64/python2.7/cookielib.pyt _cookie_attrss>    !       cCs td|jjzttj|j_|_|j|}|j|}|r|j ds|j ddj |qn|jj r|jj r|j d rx4|D])}|jdkr|j ddPqqWnWd|jjX|jdS(sAdd correct Cookie: header to request (urllib2.Request object). The Cookie2 header is also added unless policy.hide_cookie2 is true. tadd_cookie_headerRs; tCookie2is $Version="1"N(RRWtacquireRIR8RTR?R`Rht has_headertadd_unredirected_headerRRRRtreleasetclear_expired_cookies(RRR[RgR((s!/usr/lib64/python2.7/cookielib.pyRi)s$   c Csg}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| | | s, (RwRt __class__R(RtrR((s!/usr/lib64/python2.7/cookielib.pyRs cCsDg}x!|D]}|jt|q Wd|jdj|fS(Ns<%s[%s]>s, (RwR6RR(RRR((s!/usr/lib64/python2.7/cookielib.pyRs N(!RRRRytcompileReRftstrict_domain_ret domain_retdots_retmagic_reRRRZR^R`RhRiRyR~RRRRRRR{RRoRRRR(((s!/usr/lib64/python2.7/cookielib.pyRs8     ; ! a \ 6      cBseZRS((RR(((s!/usr/lib64/python2.7/cookielib.pyRscBsVeZdZdeddZdeedZdeedZdeedZRS(s6CookieJar that can be loaded from and saved to a file.cCs]tj|||dk rAy |dWqAtdqAXn||_t||_dS(s} Cookies are NOT loaded from the named file until either the .load() or .revert() method is called. R]sfilename must be string-likeN(RRRRRtfilenameRzt delayload(RRRRY((s!/usr/lib64/python2.7/cookielib.pyRs   cCs tdS(sSave cookies to a file.N(R(RRtignore_discardtignore_expires((s!/usr/lib64/python2.7/cookielib.pytsavescCsn|dkr6|jdk r'|j}q6ttnt|}z|j||||Wd|jXdS(sLoad cookies from a file.N(RRRRtMISSING_FILENAME_TEXTtopent _really_loadtclose(RRRRR((s!/usr/lib64/python2.7/cookielib.pytloads   cCs|dkr6|jdk r'|j}q6ttn|jjz\tj|j}i|_y|j |||Wn#t t fk r||_nXWd|jj XdS(sClear 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( RRRRRRWRkRtdeepcopyRXRRtIOErrorRn(RRRRt old_state((s!/usr/lib64/python2.7/cookielib.pytreverts      N( RRRRRRRRR(((s!/usr/lib64/python2.7/cookielib.pyRs  (RR(R(XRt__all__RyRRR8Rt threadingRUt ImportErrortdummy_threadingthttplibtcalendarR RR RR RR6t HTTP_PORTRRRRR$R=R>RORRwRQR<R@RFRRGRNR\R^tIRbtXRdRgRhRjRpRrRsRuRtRRRRRRRRRRRRRRRRRRRRRRRRRKRNRSRRRRt _LWPCookieJarRRt_MozillaCookieJarR(((s!/usr/lib64/python2.7/cookielib.pyts   <        "  5  8 !  U   4  '      # b![  <