Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/thread-self/root/proc/thread-self/root/proc/self/root/proc/self/root/opt/alt/python27/lib64/python2.7/
Upload File :
Current File : //proc/thread-self/root/proc/thread-self/root/proc/thread-self/root/proc/self/root/proc/self/root/opt/alt/python27/lib64/python2.7/cookielib.pyo

�
^
bc@s�dZddddddddd	g	Zd
dlZd
dlZd
dlZd
dlZd
dlZyd
dlZWne	k
r�d
dl
ZnXd
dlZd
dlm
Z
eZead
�Zeej�ZdZd�ZdZd�ZdddddddgZdddddddd d!d"d#d$gZgZx!eD]Zejej��qCWed%�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+d1�Z,ej#d2ej*�Z-d3�Z.d4�Z/ej#d5�Z0ej#d6�Z1ej#d7�Z2ej#d8�Z3d9�Z4ej#d:�Z5d;�Z6d<�Z7d=�Z8ej#d>�Z9d?�Z:d@�Z;dA�Z<dB�Z=ej#dC�Z>dD�Z?dE�Z@dF�ZAdG�ZBdHZCej#dI�ZDdJ�ZEdK�ZFdL�ZGdM�ZHdfdN��YZIdfdO��YZJdeJfdP��YZKdQ�ZLdR�ZMdSfdT��YZNdfdU��YZOdePfdV��YZQdeOfdW��YZRd
dXlSmTZTmUZUd
dYlVmWZWdS(Zs�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

tCookiet	CookieJartCookiePolicytDefaultCookiePolicyt
FileCookieJartLWPCookieJartlwp_cookie_strt	LoadErrortMozillaCookieJari����N(ttimegmcGs;ts
dSts.ddl}|jd�antj|�S(Ni����t	cookielib(tdebugtloggertloggingt	getLogger(targsR
((s./opt/alt/python27/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|dd�dS(Ni����scookielib bug!
%st
stackleveli(twarningst	tracebacktStringIOt	print_exctNonetgetvaluetwarn(RRRtftmsg((s./opt/alt/python27/lib64/python2.7/cookielib.pyt_warn_unhandled_exception9s
$i�cCs�|d \}}}}}}|tkr�d|ko?dknr�d|ko[dknr�d|kowdknr�d|ko�dknr�d|ko�dknr�t|�SdSdS(	Niiiiiii;i=(t
EPOCH_YEARR	R(ttttyeartmonthtmdaythourtmintsec((s./opt/alt/python27/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./opt/alt/python27/lib64/python2.7/cookielib.pyt	time2isozVs
%cCsl|dkrtj�}ntj|�d \}}}}}}}dt||t|d||||fS(s�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

    is#%s, %02d-%s-%04d %02d:%02d:%02d GMTiN(RR8R9tDAYStMONTHS(R:RR;R R!R"R#twday((s./opt/alt/python27/lib64/python2.7/cookielib.pyt
time2netscapegs
(tGMTtUTCtUTtZs^([-+])?(\d\d?):?(\d\d)?$cCs�d}|tkrd}ntj|�}|r�dt|jd��}|jd�rx|dt|jd��}n|jd�dkr�|}q�n|S(Niiiii<it-(Rt	UTC_ZONEStTIMEZONE_REtsearchtinttgroup(ttztoffsettm((s./opt/alt/python27/lib64/python2.7/cookielib.pytoffset_from_tz_string{s	 
c
Cs�ytj|j��d}Wn_tk
r~yt|�}Wntk
rQdSXd|koidknrw|}qdSnX|dkr�d}n|dkr�d}n|dkr�d}nt|�}t|�}t|�}t|�}t|�}|dkr�tjtj��d}|d}	|}
|||	}|	|
}	t|	�dkr�|	dkrr|d}q|d}q�nt	|||||||f�}|dk	r�|dkr�d}n|j
�}t|�}|dkr�dS||}n|S(Niiii�idi2RB(tMONTHS_LOWERtindextlowert
ValueErrorRIRR8t	localtimetabsR$tupperRN(
tdayR;tyrthrR"R#RKtimontcur_yrRMttmpR:RL((s./opt/alt/python27/lib64/python2.7/cookielib.pyt	_str2time�sR

				


!	
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*
    )?$cCs4tj|�}|r�|j�}tj|dj��d}t|d�|t|d�t|d�t|d�t|d�f}t|�S|j	�}t
jd|d�}d	gd\}}}}}}	}
t
j|�}|d	k	r|j�\}}}}}}	}
nd	St||||||	|
�S(
s�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.

    iiiiiitiN(tSTRICT_DATE_RERHtgroupsRORPRQRItfloatR$tlstript
WEEKDAY_REtsubRtLOOSE_HTTP_DATE_RER\(ttextRMtgR;RRVRWRXR"R#RK((s./opt/alt/python27/lib64/python2.7/cookielib.pyt	http2time�s-
"$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(RaRtISO_DATE_RERHR_R\(
ReRVR;RWRXR"R#RKRMt_((s./opt/alt/python27/lib64/python2.7/cookielib.pytiso2time"s
"'cCs+|jd�\}}|j| |j|S(s)Return unmatched part of re.Match object.i(tspantstring(tmatchtstarttend((s./opt/alt/python27/lib64/python2.7/cookielib.pyt	unmatchedCss^\s*([^=\s;,]+)s&^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"s^\s*=\s*([^\s;,]*)s\\(.)c
Csg}xr|D]j}|}g}x?|r`tj|�}|r�t|�}|jd�}tj|�}|r�t|�}|jd�}tjd|�}nEtj|�}|r�t|�}|jd�}|j�}nd}|j
||f�q"|j�jd�r<|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*<any CHAR except CTLs or separators>
      separators        = "(" | ")" | "<" | ">" | "@"
                        | "," | ";" | ":" | "\" | <">
                        | "/" | "[" | "]" | "?" | "="
                        | "{" | "}" | SP | HT

      quoted-string     = ( <"> *(qdtext | quoted-pair ) <"> )
      qdtext            = <any TEXT except <">>
      quoted-pair       = "\" CHAR

      parameter         = attribute "=" value
      attribute         = token
      value             = token | quoted-string

    Each header is represented by a list of key/value pairs.  The value for a
    simple token (not part of a parameter) is None.  Syntactically incorrect
    headers will not necessarily be parsed as you would want.

    This is easier to describe with some examples:

    >>> split_header_words(['foo="bar"; port="80,81"; discard, bar=baz'])
    [[('foo', 'bar'), ('port', '80,81'), ('discard', None)], [('bar', 'baz')]]
    >>> split_header_words(['text/html; charset="iso-8859-1"'])
    [[('text/html', None), ('charset', 'iso-8859-1')]]
    >>> split_header_words([r'Basic realm="\"foo\bar\""'])
    [[('Basic', None), ('realm', '"foobar"')]]

    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./opt/alt/python27/lib64/python2.7/cookielib.pytsplit_header_wordsLs>.
		
s([\"\\])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(s�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"'

    s^\w+$s\\\1s"%s"s%s=%ss; s, N(RRyRHtHEADER_JOIN_ESCAPE_RERcRwtjoin(tliststheadersR~tattrtktv((s./opt/alt/python27/lib64/python2.7/cookielib.pytjoin_header_words�s

cCs<|jd�r|d}n|jd�r8|d }n|S(Nt"ii����(Rxtendswith(Re((s./opt/alt/python27/lib64/python2.7/cookielib.pyt
_strip_quotes�s


cCs�d}g}xs|D]k}g}t}x*t|jd��D]\}}|j�}|jd	�\}}	}
|j�}|s�|d
kr;Pq�q;n|	r�|
j�nd
}
|d
kr;|j�}||kr�|}n|dkr|
d
k	r�t|
�}
nt}q;|dkr;|
d
k	r8t	t|
��}
q8q;n|j
||
f�q;W|r|sn|j
d�n|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-aget;t=it0(R�R�R�R�R�R�smax-ageN(R�R�(tFalset	enumeratetsplittstript	partitionRRQR�tTrueRgRw(t
ns_headerstknown_attrsR|t	ns_headerR~tversion_settiitparamtkeytseptvaltlc((s./opt/alt/python27/lib64/python2.7/cookielib.pytparse_ns_headers�s@
"		s\.\d+$cCsKtj|�rtS|dkr#tS|ddksC|ddkrGtStS(s*Return True if text is a host domain name.R]it.i����(tIPV4_RERHR�R�(Re((s./opt/alt/python27/lib64/python2.7/cookielib.pytis_HDNs cCs�|j�}|j�}||kr(tSt|�s8tS|j|�}|dks_|dkrctS|jd�svtSt|d�s�tStS(s�Return True if domain A domain-matches domain B, according to RFC 2965.

    A and B may be host domain names or IP addresses.

    RFC 2965, section 1:

    Host names can be specified either as an IP address or a HDN string.
    Sometimes we compare one host name with another.  (Such comparisons SHALL
    be case-insensitive.)  Host A's name domain-matches host B's if

         *  their host name strings string-compare equal; or

         * A is a HDN string and has the form NB, where N is a non-empty
            name string, B has the form .B', and B' is a HDN string.  (So,
            x.y.com domain-matches .Y.com but not Y.com.)

    Note that domain-match is not a commutative operation: a.b.c.com
    domain-matches .c.com, but not the reverse.

    i����iR�i(RQR�R�R�trfindRx(tAtBti((s./opt/alt/python27/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.

    (R�RHR�R�(Re((s./opt/alt/python27/lib64/python2.7/cookielib.pytliberal_is_HDN=scCs�|j�}|j�}t|�o-t|�sD||kr@tStS|jd�}|rl|j|�rltS|r�||kr�tStS(s\For blocking/accepting domains.

    A and B may be host domain names or IP addresses.

    R�(RQR�R�R�RxR�(R�R�tinitial_dot((s./opt/alt/python27/lib64/python2.7/cookielib.pytuser_domain_matchGss:\d+$cCs_|j�}tj|�d}|dkr@|jdd�}ntjd|d�}|j�S(s�Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    iR]tHost(tget_full_urlturlparset
get_headertcut_port_reRcRQ(trequestturlthost((s./opt/alt/python27/lib64/python2.7/cookielib.pytrequest_host\scCsLt|�}}|jd�dkrBtj|�rB|d}n||fS(szReturn a tuple (request-host, effective request-host name).

    As defined by RFC 2965, except both are lowercased.

    R�i����s.local(R�tfindR�RH(R�terhntreq_host((s./opt/alt/python27/lib64/python2.7/cookielib.pyteff_request_hostls%
cCsJ|j�}tj|�}t|j�}|jd�sFd|}n|S(s6Path component of request-URI, as defined by RFC 2965.t/(R�R�turlsplittescape_pathR�Rx(R�R�tpartsR�((s./opt/alt/python27/lib64/python2.7/cookielib.pytrequest_pathws
cCsr|j�}|jd�}|dkrh||d}yt|�Wqntk
rdtd|�dSXnt}|S(Nt:iisnonnumeric port: '%s'(tget_hostR�RIRRRRtDEFAULT_HTTP_PORT(R�R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytrequest_port�s

s%/;:@&=+$,!~*'()s%([0-9a-fA-F][0-9a-fA-F])cCsd|jd�j�S(Ns%%%si(RJRU(Rm((s./opt/alt/python27/lib64/python2.7/cookielib.pytuppercase_escaped_char�scCsIt|t�r!|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./opt/alt/python27/lib64/python2.7/cookielib.pyR��s

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'

    R�iitlocal(R�R�(thR�tb((s./opt/alt/python27/lib64/python2.7/cookielib.pytreach�s$cCs3t|�}t|t|j���s+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(R�R�R�tget_origin_req_hostR�R�(R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytis_third_party�s
cBsVeZdZed�Zd�Zdd�Zd�Zdd�Z	d�Z
d�ZRS(	s�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]|tkr]td��n||_||_||_||_||_|j	�|_
||_||_|	|_
|
|_||_||_|
|_||_||_||_tj|�|_dS(Ns-if port is None, port_specified must be false(RRIR�RRR�RR�R�tport_specifiedRQR�tdomain_specifiedtdomain_initial_dotR�tpath_specifiedR�R�tdiscardtcommenttcomment_urltrfc2109tcopyt_rest(tselfR�RR�R�R�R�R�R�R�R�R�R�R�R�R�trestR�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt__init__�s.
															cCs
||jkS(N(R�(R�R((s./opt/alt/python27/lib64/python2.7/cookielib.pythas_nonstandard_attrscCs|jj||�S(N(R�tget(R�Rtdefault((s./opt/alt/python27/lib64/python2.7/cookielib.pytget_nonstandard_attrscCs||j|<dS(N(R�(R�RR�((s./opt/alt/python27/lib64/python2.7/cookielib.pytset_nonstandard_attrscCsA|dkrtj�}n|jdk	r=|j|kr=tStS(N(RR8R�R�R�(R�tnow((s./opt/alt/python27/lib64/python2.7/cookielib.pyt
is_expireds
cCsx|jdkrd}n
d|j}|j||j}|jdk	rad|j|jf}n	|j}d||fS(NR]R�s%s=%ss<Cookie %s for %s>(R�RR�R�R�R(R�tptlimitt	namevalue((s./opt/alt/python27/lib64/python2.7/cookielib.pyt__str__"s	
	cCs�g}x:dD]2}t||�}|jd|t|�f�q
W|jdt|j��|jdt|j��ddj|�S(NR�RR�R�R�R�R�R�R�R�R�R�R�R�R�s%s=%ssrest=%ss
rfc2109=%ss
Cookie(%s)s, (R�RR�R�R�R�R�R�R�R�R�R�R�R�R�(tgetattrRwtreprR�R�R�(R�RRR�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt__repr__,s
!N(t__name__t
__module__t__doc__R�R�R�RR�R�R�R�R�(((s./opt/alt/python27/lib64/python2.7/cookielib.pyR�s 			
cBs2eZdZd�Zd�Zd�Zd�ZRS(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
t��dS(s�Return true if (and only if) cookie should be accepted from server.

        Currently, pre-expired cookies never get this far -- the CookieJar
        class deletes such cookies itself.

        N(tNotImplementedError(R�tcookieR�((s./opt/alt/python27/lib64/python2.7/cookielib.pytset_okDscCs
t��dS(sAReturn true if (and only if) cookie should be returned to server.N(R�(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt	return_okMscCstS(sMReturn false if cookies should not be returned, given cookie domain.
        (R�(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytdomain_return_okQscCstS(sKReturn false if cookies should not be returned, given cookie path.
        (R�(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytpath_return_okVs(R�R�R�R�R�R�R�(((s./opt/alt/python27/lib64/python2.7/cookielib.pyR;s
				c
Bs#eZdZdZdZdZdZeeBZdde	e
de
e
e	e
ee
e
d�Zd�Zd�Z
d�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!RS(sBImplements the standard rules for accepting and returning cookies.iiiic

Cs�||_||_||_||_||_||_|	|_|
|_||_||_	|dk	rxt|�|_n	d|_|dk	r�t|�}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(
R�tblocked_domainstallowed_domainsR�R�R�R�RRRRRR((s./opt/alt/python27/lib64/python2.7/cookielib.pyR�fs 
											cCs|jS(s4Return the sequence of blocked domains (as a tuple).(R(R�((s./opt/alt/python27/lib64/python2.7/cookielib.pyR	�scCst|�|_dS(s$Set the sequence of blocked domains.N(RR(R�R	((s./opt/alt/python27/lib64/python2.7/cookielib.pytset_blocked_domains�scCs+x$|jD]}t||�r
tSq
WtS(N(RR�R�R�(R�R�tblocked_domain((s./opt/alt/python27/lib64/python2.7/cookielib.pyt
is_blocked�scCs|jS(s=Return None, or the sequence of allowed domains (as a tuple).(R(R�((s./opt/alt/python27/lib64/python2.7/cookielib.pyR
�scCs(|dk	rt|�}n||_dS(s-Set the sequence of allowed domains, or None.N(RRR(R�R
((s./opt/alt/python27/lib64/python2.7/cookielib.pytset_allowed_domains�scCs>|jdkrtSx$|jD]}t||�rtSqWtS(N(RRR�R�R�(R�R�tallowed_domain((s./opt/alt/python27/lib64/python2.7/cookielib.pytis_not_allowed�scCsWtd|j|j�x: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=%sR�t
verifiabilityRR�R�R�tset_ok_(R�RRR�R�R�(RRR�R�R�R�(R�R�R�tntfn_nametfn((s./opt/alt/python27/lib64/python2.7/cookielib.pyR��s

cCs{|jdkr)td|j|j�tS|jdkrP|jrPtd�tS|jdkrw|jrwtd�tStS(Ns0   Set-Cookie2 without version attribute (%s=%s)is$   RFC 2965 cookies are switched offs$   Netscape cookies are switched off(	R�RRRR�R�R�R�R�(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytset_ok_version�s

cCsk|j�rgt|�rg|jdkr>|jr>td�tS|jdkrg|jrgtd�tSntS(Nis>   third-party RFC 2965 cookie during unverifiable transactions>   third-party Netscape cookie during unverifiable transaction(tis_unverifiableR�R�RRR�RR�(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytset_ok_verifiability�s

cCsB|jdkr>|jr>|jjd�r>td|j�tStS(Nit$s'   illegal name (starts with '$'): '%s'(R�RRRxRR�R�(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytset_ok_name�s
cCsp|jrlt|�}|jdks<|jdkrl|jrl|j|j|�rltd|j|�tSntS(Nis7   path attribute %s is not a prefix of request path %s(	R�R�R�RR�R�RR�R�(R�R�R�treq_path((s./opt/alt/python27/lib64/python2.7/cookielib.pytset_ok_path�s	
c
Cs�|j|j�r&td|j�tS|j|j�rLtd|j�tS|jr�t|�\}}|j}|jr|jd�dkr|j	d�}|j	dd|�}|dkr||d}||d|!}	|	j
�d"krt|�dkrtd|�tSqn|jd�r4|d}
n|}
|
j
d�dk}|rs|dkrstd|�tS|jdkr�|j|�r�|jd�r�d|j|�r�td||�tSn|jdks�|j|j@rt||�std ||�tSn|jdks1|j|j@r�|t|� }|j
d�dkr~tj|�r~td!||�tSq�ntS(#Ns"   domain %s is in user block-lists&   domain %s is not in user allow-listR�iiitcotactcomtedutorgtnettgovtmilRItaerotbiztcattcooptinfotjobstmobitmuseumRtprottravelteus&   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(RRRR R!R"R#R$RIR%R&R'R(R)R*R+R,RR-R.R/(R
R�RR�RR�R�RtcountR�RQtlenRxR�R�R�RtDomainRFC2965MatchR�tDomainStrictNoDotsR�RHR�(
R�R�R�R�R�R�R�tjttldtsldtundotted_domaint
embedded_dotsthost_prefix((s./opt/alt/python27/lib64/python2.7/cookielib.pyt
set_ok_domain�sf			






cCs�|jr�t|�}|dkr*d}nt|�}xt|jjd�D]F}yt|�Wntk
r~td|�t	SX||krIPqIqIWtd||j�t	Snt
S(Nt80Rqs   bad port %s (not numeric)s$   request port (%s) not found in %s(R�R�RtstrR�R�RIRRRR�R�(R�R�R�treq_portR�((s./opt/alt/python27/lib64/python2.7/cookielib.pytset_ok_port"s"		


cCsWtd|j|j�x: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=%sR�RR�R�R�R�t
return_ok_(R�RR�R�R�R�(RRR�R�R�R�(R�R�R�RRR((s./opt/alt/python27/lib64/python2.7/cookielib.pyR�7s	

cCsR|jdkr'|jr'td�tS|jdkrN|jrNtd�tStS(Nis$   RFC 2965 cookies are switched offs$   Netscape cookies are switched off(R�R�RR�R�R�(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytreturn_ok_versionIs

cCsk|j�rgt|�rg|jdkr>|jr>td�tS|jdkrg|jrgtd�tSntS(Nis>   third-party RFC 2965 cookie during unverifiable transactions>   third-party Netscape cookie during unverifiable transaction(RR�R�RRR�RR�(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytreturn_ok_verifiabilityRs

cCs-|jr)|j�dkr)td�tStS(Nthttpss(   secure cookie with non-secure request(R�tget_typeRR�R�(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytreturn_ok_secure^s
cCs$|j|j�r td�tStS(Ns   cookie expired(R�t_nowRR�R�(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytreturn_ok_expiresds
cCsu|jrqt|�}|dkr*d}nxD|jjd�D]}||kr=Pq=q=Wtd||j�tSntS(NR;Rqs0   request port %s does not match cookie port %s(R�R�RR�RR�R�(R�R�R�R=R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytreturn_ok_portjs		
cCs�t|�\}}|j}|r>|jd�r>d|}n|}|jdkr�|j|j@r�|jr�||kr�td�tS|jdkr�t	||�r�td||�tS|jdkr�d|j
|�r�td||�tStS(NR�isQ   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(R�R�RxR�RtDomainStrictNonDomainR�RR�R�R�R�(R�R�R�R�R�R�t	dotdomain((s./opt/alt/python27/lib64/python2.7/cookielib.pytreturn_ok_domainxs&	


#
cCs�t|�\}}|jd�s.d|}n|jd�sJd|}n|rm|jd�rmd|}n|}|j|�p�|j|�s�tS|j|�r�td|�tS|j|�r�td|�tStS(NR�s"   domain %s is in user block-lists&   domain %s is not in user allow-list(R�RxR�R�R
RRR�(R�R�R�R�R�RI((s./opt/alt/python27/lib64/python2.7/cookielib.pyR��s"




cCs�td|�t|�}t|�}||kr5tS|j|�rn|jd�sj|||d!dkrntStd||�tS(Ns- checking cookie path=%sR�is  %s does not path-match %s(RR�R1R�RxR�R�(R�R�R�Rtpathlen((s./opt/alt/python27/lib64/python2.7/cookielib.pyR��s
&N("R�R�R�R3RHR2t
DomainLiberaltDomainStrictRR�R�R�R	RR
R
RRR�RRRRR:R>R�R@RARDRFRGRJR�R�(((s./opt/alt/python27/lib64/python2.7/cookielib.pyR\sL
													;										cCs&|j�}|j�t|j|�S(N(tkeystsorttmapR�(tadictRN((s./opt/alt/python27/lib64/python2.7/cookielib.pytvals_sorted_by_key�s
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(RRR�titemstAttributeErrorR�t
deepvalues(tmappingtvaluestobjtsubobj((s./opt/alt/python27/lib64/python2.7/cookielib.pyRU�s

	tAbsentcBseZRS((R�R�(((s./opt/alt/python27/lib64/python2.7/cookielib.pyRZ�scBs(eZdZejd�Zejd�Zejd�Zejd�Zejd�Z	dZ
dd�Zd�Z
d	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdddd�Zd�Zd�Zd�Zd�Zd�Zd�Z RS(s�Collection 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(R�tpolicy((s./opt/alt/python27/lib64/python2.7/cookielib.pyR��s
	cCs
||_dS(N(R[(R�R`((s./opt/alt/python27/lib64/python2.7/cookielib.pyt
set_policy�scCs�g}|jj||�sgStd|�|j|}x�|j�D]~}|jj||�sgqFn||}xP|j�D]B}|jj||�s�td�q~ntd�|j|�q~WqFW|S(Ns!Checking %s for cookies to returns   not returning cookies   it's a match(	R[R�RR_RNR�RWR�Rw(R�R�R�tcookiestcookies_by_pathR�tcookies_by_nameR�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt_cookies_for_domain�s 




cCs=g}x0|jj�D]}|j|j||��qW|S(s2Return a list of cookies to be returned to server.(R_RNtextendRe(R�R�RbR�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt_cookies_for_requestsc	Cs�|jdd�dt�t}g}x�|D]�}|j}|sjt}|dkrj|jd|�qjn|jdk	r�|jj|j�r�|dkr�|j	j
d|j�}n	|j}|jdkr�|j|j�n|jd|j|f�|dkr,|jr&|jd|j
�n|jjd	�r{|j}|jrg|jd	�rg|d
}n|jd|�n|jdk	r�d}|jr�|d
|j}n|j|�q�q,q,W|S(s�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).

        R�cSs
t|j�S(N(R1R�(targ((s./opt/alt/python27/lib64/python2.7/cookielib.pyt<lambda>R]treverseis$Version=%ss\\\1s%s=%ss
$Path="%s"R�is$Domain="%s"s$Ports="%s"N(ROR�R�R�RwR�Rtnon_word_reRHtquote_reRcRR�R�R�RxR�R�R�(	R�RbR�tattrsR�R�R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt
_cookie_attrss>

	!			

	cCstd�|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(s�Add 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(RR^tacquireRIR8R[RERgRnt
has_headertadd_unredirected_headerR�R�R�R�treleasetclear_expired_cookies(R�R�RbRmR�((s./opt/alt/python27/lib64/python2.7/cookielib.pyRoCs$


cCsg}d}d}x|D]�}|d\}}t}t}	i}
i}x�|dD]�\}}
|j�}||ks�||kr�|}n||kr�|
dkr�t}
n||
kr�qRn|dkr�|
dkr�td
�t}	Pn|
j�}
n|dkr0|rqRn|
dkr0td�qRq0n|dkr�t}yt|
�}
Wn"tk
rvtd�t}	PnXd}|j|
}
n||ks�||kr�|
dkr�|dkr�td|�t}	Pn|
|
|<qR|
||<qRW|	r�qn|j|||
|f�qW|S(sReturn list of tuples containing normalised cookie information.

        attrs_set is the list of lists of key,value pairs extracted from
        the Set-Cookie or Set-Cookie2 headers.

        Tuples are name, value, standard, rest, where name and value are the
        cookie name and value, standard is a dictionary containing the standard
        cookie-attributes (discard, secure, version, expires or max-age,
        domain, path and port) and rest is a dictionary containing the rest of
        the cookie-attributes.

        R�R�R�R�smax-ageR�R�R�R�t
commenturliis%   missing value for domain attributesM   missing or invalid value for expires attribute: treating as session cookies?   missing or invalid (non-numeric) value for max-age attributes!   missing value for %s attribute(R�R�(R�R�smax-ageR�R�R�R�RvN(R�R�Rv(	R�RQRR�RRIRRRERw(R�t	attrs_sett
cookie_tuplest
boolean_attrstvalue_attrstcookie_attrsRR�tmax_age_sett
bad_cookietstandardR�R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt_normalized_cookie_tuplesdsl


		

	


cCs�|\}}}}|jdt�}|jdt�}|jdt�}	|jdt�}
|jdd�}|dk	r�yt|�}Wq�tk
r�dSXn|jdt�}|jdt�}
|jdd�}|jd	d�}|tk	r|d
krt}t|�}nrt}t|�}|j	d�}|dkrl|d
kr[|| }ql||d }nt
|�d
kr�d}n|tk	}t}|r�t|jd��}n|tkr�t
|�\}}|}n|jd�s�d|}nt}|	tk	rE|	dkr't|�}	qKt}tjdd
|	�}	nd}	|
tkrfd}
t}
nQ|
|jkr�y|j|||�Wntk
r�nXtd|||�dSt||||	||||||||
|
|||�S(NR�R�R�R�R�R�R�R�RvR]R�i����iiR�s\s+s2Expiring cookie, domain='%s', path='%s', name='%s'(R�RZRRIRRR�R�R�R�R�R1tboolRxR�R�RyRcREtcleartKeyErrorRR(R�ttupR�RR�R~R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt_cookie_from_cookie_tuple�s�

		
	

	cCsR|j|�}g}x6|D].}|j||�}|r|j|�qqW|S(N(RR�Rw(R�RwR�RxRbR�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt_cookies_from_attrs_set!s
cCsst|jdd�}|dkr1|jj}nx;|D]3}|jdkr8t|_|rkd|_qkq8q8WdS(NR�ii(R�R[RR�R�R�R�(R�Rbt
rfc2109_as_nsR�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt_process_rfc2109_cookies*s
	c
Cs�|j�}|jd�}|jd�}|jj}|jj}|rP|sz|r^|sz|rl|sz|r~|r~gSy|jt|�|�}Wntk
r�t�g}nX|r�|r�y|jt	|�|�}	Wntk
rt�g}	nX|j
|	�|rhi}
x*|D]"}d|
|j|j
|jf<q$W|
d�}t||	�}	n|	r�|j|	�q�n|S(sAReturn sequence of Cookie objects extracted from response object.sSet-Cookie2s
Set-CookiecSs"|j|j|jf}||kS(N(R�R�R(t	ns_cookietlookupR�((s./opt/alt/python27/lib64/python2.7/cookielib.pytno_matching_rfc2965bsN(R)t
getheadersR[R�R�R�R�t	ExceptionRR�R�RR�R�RtfilterRf(
R�tresponseR�R�trfc2965_hdrstns_hdrsR�R�Rbt
ns_cookiesR�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytmake_cookies6sB





 cCsj|jj�zHttj��|j_|_|jj||�rT|j|�nWd|jj�XdS(s-Set a cookie if policy says it's OK to do so.N(	R^RqRIR8R[RER�t
set_cookieRt(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytset_cookie_if_okls
cCs�|j}|jj�zi|j|kr8i||j<n||j}|j|krdi||j<n||j}|||j<Wd|jj�XdS(s?Set a cookie, without checking whether or not it should be set.N(R_R^RqR�R�RRt(R�R�tctc2tc3((s./opt/alt/python27/lib64/python2.7/cookielib.pyR�ys	


cCs�td|j��|jj�zrttj��|j_|_xL|j||�D]8}|jj	||�rUtd|�|j
|�qUqUWWd|jj�XdS(sAExtract cookies from response, where allowable given the request.sextract_cookies: %ss setting cookie: %sN(RR)R^RqRIR8R[RER�R�R�Rt(R�R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytextract_cookies�s

cCs�|dk	rH|dks$|dkr3td��n|j|||=nZ|dk	r�|dkrotd��n|j||=n"|dk	r�|j|=n	i|_dS(s�Clear some cookies.

        Invoking this method without arguments will clear all cookies.  If
        given a single argument, only cookies belonging to that domain will be
        removed.  If given two arguments, cookies belonging to the specified
        path within that domain are removed.  If given three arguments, then
        the cookie with the specified name, path and domain is removed.

        Raises KeyError if no matching cookie exists.

        s8domain and path must be given to remove a cookie by names.domain must be given to remove cookies by pathN(RRRR_(R�R�R�R((s./opt/alt/python27/lib64/python2.7/cookielib.pyR��s
cCs_|jj�z=x6|D].}|jr|j|j|j|j�qqWWd|jj�XdS(s�Discard all session cookies.

        Note that the .save() method won't save session cookies anyway, unless
        you ask otherwise by passing a true ignore_discard argument.

        N(R^RqR�R�R�R�RRt(R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pytclear_session_cookies�s

	'cCsq|jj�zOtj�}x<|D]4}|j|�r#|j|j|j|j�q#q#WWd|jj�XdS(s�Discard all expired cookies.

        You probably don't need to call this method: expired cookies are never
        sent back to the server (provided you're using DefaultCookiePolicy),
        this method is called by CookieJar itself every so often, and the
        .save() method won't save expired cookies anyway (unless you ask
        otherwise by passing a true ignore_expires argument).

        N(	R^RqR8R�R�R�R�RRt(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pyRu�s


'cCs
t|j�S(N(RUR_(R�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt__iter__�scCs%d}x|D]}|d}q
W|S(s#Return number of contained cookies.ii((R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pyt__len__�s
cCsGg}x!|D]}|jt|��q
Wd|jjdj|�fS(Ns<%s[%s]>s, (RwR�t	__class__R�R�(R�trR�((s./opt/alt/python27/lib64/python2.7/cookielib.pyR��s
cCsGg}x!|D]}|jt|��q
Wd|jjdj|�fS(Ns<%s[%s]>s, (RwR<R�R�R�(R�R�R�((s./opt/alt/python27/lib64/python2.7/cookielib.pyR��s
N(!R�R�R�RytcompileRkRltstrict_domain_ret	domain_retdots_retmagic_reRR�RaReRgRnRoRR�R�R�R�R�R�R�R�R�RuR�R�R�R�(((s./opt/alt/python27/lib64/python2.7/cookielib.pyR�s8				;	!	a	\				6	
	
						cBseZRS((R�R�(((s./opt/alt/python27/lib64/python2.7/cookielib.pyR�scBsVeZdZdedd�Zdeed�Zdeed�Zdeed�ZRS(s6CookieJar that can be loaded from and saved to a file.cCs]tj||�|dk	rAy|dWqAtd��qAXn||_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(RR�RRRtfilenameR�t	delayload(R�R�R�R`((s./opt/alt/python27/lib64/python2.7/cookielib.pyR��s	cCs
t��dS(sSave cookies to a file.N(R�(R�R�tignore_discardtignore_expires((s./opt/alt/python27/lib64/python2.7/cookielib.pytsave�scCsn|dkr6|jdk	r'|j}q6tt��nt|�}z|j||||�Wd|j�XdS(sLoad cookies from a file.N(RR�RRtMISSING_FILENAME_TEXTtopent_really_loadtclose(R�R�R�R�R((s./opt/alt/python27/lib64/python2.7/cookielib.pytload�scCs�|dkr6|jdk	r'|j}q6tt��n|jj�z\tj|j�}i|_y|j	|||�Wn#t
tfk
r�||_�nXWd|jj�XdS(s�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(
RR�RRR�R^RqR�tdeepcopyR_R�RtIOErrorRt(R�R�R�R�t	old_state((s./opt/alt/python27/lib64/python2.7/cookielib.pytrevert
s
		N(	R�R�R�RR�R�R�R�R�(((s./opt/alt/python27/lib64/python2.7/cookielib.pyR�s(RR(R(XR�t__all__RyR�R�R8R�t	threadingR\tImportErrortdummy_threadingthttplibtcalendarR	R�RRRRR<t	HTTP_PORTR�R�RRR$R=R>RORRwRQR<R@RFR�RGRNR\R^tIRbtXRdRgRhRjRpRrRsRuRtR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRRRRRURZRR�RRt
_LWPCookieJarRRt_MozillaCookieJarR(((s./opt/alt/python27/lib64/python2.7/cookielib.pyt<module>s�	<
	
		
"		5		8	!		U			D		'	
				
				#	b!�_		��<

Hacked By AnonymousFox1.0, Coded By AnonymousFox