ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/lib64/python2.7/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/lib64/python2.7/Cookie.pyo

�
zfc
@s�dZddlZyddlmZmZWn'ek
rUddlmZmZnXddlZddlZdddddd	gZ	d
j
Zdj
Zdj
Z
defd
��YZejejdZi�dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dKdL6dMdN6dOdP6dQdR6dSdT6dUdV6dWdX6dYdZ6d[d\6d]d^6d_d`6dadb6dcdd6dedf6dgdh6didj6dkdl6dmdn6dodp6dqdr6dsdt6dudv6dwdx6dydz6d{d|6d}d~6dd�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d�6d�d6dd6dd6dd6dd6d	d
6dd6d
d6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d1d26d3d46d5d66d7d86d9d:6d;d<6d=d>6d?d@6dAdB6dCdD6dEdF6dGdH6dIdJ6dKdL6dMdN6dOdP6dQdR6dSdT6dUdV6dWdX6Zd
j
dY�edZ�D��Zeeejd[�Zejd\�Zejd]�Zd^�Zd_d`dadbdcdddegZddfdgdhdidjdkdldmdndodpdqg
Zdreeds�Zdte fdu��YZ!dvZ"e"dwZ#ejdxe"dye#dz�Z$de fd{��YZ%de%fd|��YZ&de%fd}��YZ'de%fd~��YZ(e(Z)d�Z*e+d�kr�e*�ndS(�s)
Here's a sample session to show how to use this module.
At the moment, this is the only documentation.

The Basics
----------

Importing is easy..

   >>> import Cookie

Most of the time you start by creating a cookie.  Cookies come in
three flavors, each with slightly different encoding semantics, but
more on that later.

   >>> C = Cookie.SimpleCookie()
   >>> C = Cookie.SerialCookie()
   >>> C = Cookie.SmartCookie()

[Note: Long-time users of Cookie.py will remember using
Cookie.Cookie() to create a Cookie object.  Although deprecated, it
is still supported by the code.  See the Backward Compatibility notes
for more information.]

Once you've created your Cookie, you can add values just as if it were
a dictionary.

   >>> C = Cookie.SmartCookie()
   >>> C["fig"] = "newton"
   >>> C["sugar"] = "wafer"
   >>> C.output()
   'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer'

Notice that the printable representation of a Cookie is the
appropriate format for a Set-Cookie: header.  This is the
default behavior.  You can change the header and printed
attributes by using the .output() function

   >>> C = Cookie.SmartCookie()
   >>> C["rocky"] = "road"
   >>> C["rocky"]["path"] = "/cookie"
   >>> print C.output(header="Cookie:")
   Cookie: rocky=road; Path=/cookie
   >>> print C.output(attrs=[], header="Cookie:")
   Cookie: rocky=road

The load() method of a Cookie extracts cookies from a string.  In a
CGI script, you would use this method to extract the cookies from the
HTTP_COOKIE environment variable.

   >>> C = Cookie.SmartCookie()
   >>> C.load("chips=ahoy; vienna=finger")
   >>> C.output()
   'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'

The load() method is darn-tootin smart about identifying cookies
within a string.  Escaped quotation marks, nested semicolons, and other
such trickeries do not confuse it.

   >>> C = Cookie.SmartCookie()
   >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
   >>> print C
   Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"

Each element of the Cookie also supports all of the RFC 2109
Cookie attributes.  Here's an example which sets the Path
attribute.

   >>> C = Cookie.SmartCookie()
   >>> C["oreo"] = "doublestuff"
   >>> C["oreo"]["path"] = "/"
   >>> print C
   Set-Cookie: oreo=doublestuff; Path=/

Each dictionary element has a 'value' attribute, which gives you
back the value associated with the key.

   >>> C = Cookie.SmartCookie()
   >>> C["twix"] = "none for you"
   >>> C["twix"].value
   'none for you'


A Bit More Advanced
-------------------

As mentioned before, there are three different flavors of Cookie
objects, each with different encoding/decoding semantics.  This
section briefly discusses the differences.

SimpleCookie

The SimpleCookie expects that all values should be standard strings.
Just to be sure, SimpleCookie invokes the str() builtin to convert
the value to a string, when the values are set dictionary-style.

   >>> C = Cookie.SimpleCookie()
   >>> C["number"] = 7
   >>> C["string"] = "seven"
   >>> C["number"].value
   '7'
   >>> C["string"].value
   'seven'
   >>> C.output()
   'Set-Cookie: number=7\r\nSet-Cookie: string=seven'


SerialCookie

The SerialCookie expects that all values should be serialized using
cPickle (or pickle, if cPickle isn't available).  As a result of
serializing, SerialCookie can save almost any Python object to a
value, and recover the exact same object when the cookie has been
returned.  (SerialCookie can yield some strange-looking cookie
values, however.)

   >>> C = Cookie.SerialCookie()
   >>> C["number"] = 7
   >>> C["string"] = "seven"
   >>> C["number"].value
   7
   >>> C["string"].value
   'seven'
   >>> C.output()
   'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string="S\'seven\'\\012p1\\012."'

Be warned, however, if SerialCookie cannot de-serialize a value (because
it isn't a valid pickle'd object), IT WILL RAISE AN EXCEPTION.


SmartCookie

The SmartCookie combines aspects of each of the other two flavors.
When setting a value in a dictionary-fashion, the SmartCookie will
serialize (ala cPickle) the value *if and only if* it isn't a
Python string.  String objects are *not* serialized.  Similarly,
when the load() method parses out values, it attempts to de-serialize
the value.  If it fails, then it fallsback to treating the value
as a string.

   >>> C = Cookie.SmartCookie()
   >>> C["number"] = 7
   >>> C["string"] = "seven"
   >>> C["number"].value
   7
   >>> C["string"].value
   'seven'
   >>> C.output()
   'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string=seven'


Backwards Compatibility
-----------------------

In order to keep compatibility with earlier versions of Cookie.py,
it is still possible to use Cookie.Cookie() to create a Cookie.  In
fact, this simply returns a SmartCookie.

   >>> C = Cookie.Cookie()
   >>> print C.__class__.__name__
   SmartCookie


Finis.
i����N(tdumpstloadstCookieErrort
BaseCookietSimpleCookietSerialCookietSmartCookietCookiets; t cBseZRS((t__name__t
__module__(((s/usr/lib64/python2.7/Cookie.pyR�ss!#$%&'*+-.^_`|~s\000ss\001ss\002ss\003ss\004ss\005ss\006ss\007ss\010ss\011s	s\012s
s\013ss\014ss\015s
s\016ss\017ss\020ss\021ss\022ss\023ss\024ss\025ss\026ss\027ss\030ss\031ss\032ss\033ss\034ss\035ss\036ss\037ss\054t,s\073t;s\"t"s\\s\s\177ss\200s�s\201s�s\202s�s\203s�s\204s�s\205s�s\206s�s\207s�s\210s�s\211s�s\212s�s\213s�s\214s�s\215s�s\216s�s\217s�s\220s�s\221s�s\222s�s\223s�s\224s�s\225s�s\226s�s\227s�s\230s�s\231s�s\232s�s\233s�s\234s�s\235s�s\236s�s\237s�s\240s�s\241s�s\242s�s\243s�s\244s�s\245s�s\246s�s\247s�s\250s�s\251s�s\252s�s\253s�s\254s�s\255s�s\256s�s\257s�s\260s�s\261s�s\262s�s\263s�s\264s�s\265s�s\266s�s\267s�s\270s�s\271s�s\272s�s\273s�s\274s�s\275s�s\276s�s\277s�s\300s�s\301s�s\302s�s\303s�s\304s�s\305s�s\306s�s\307s�s\310s�s\311s�s\312s�s\313s�s\314s�s\315s�s\316s�s\317s�s\320s�s\321s�s\322s�s\323s�s\324s�s\325s�s\326s�s\327s�s\330s�s\331s�s\332s�s\333s�s\334s�s\335s�s\336s�s\337s�s\340s�s\341s�s\342s�s\343s�s\344s�s\345s�s\346s�s\347s�s\350s�s\351s�s\352s�s\353s�s\354s�s\355s�s\356s�s\357s�s\360s�s\361s�s\362s�s\363s�s\364s�s\365s�s\366s�s\367s�s\370s�s\371s�s\372s�s\373s�s\374s�s\375s�s\376s�s\377s�ccs|]}t|�VqdS(N(tchr(t.0tx((s/usr/lib64/python2.7/Cookie.pys	<genexpr>6sicCsAd||||�kr|Sdtttj||��dSdS(NRR(t	_nulljointmapt_Translatortget(tstrt
LegalCharstidmapt	translate((s/usr/lib64/python2.7/Cookie.pyt_quote8ss\\[0-3][0-7][0-7]s[\\].cCs�t|�dkr|S|ddks6|ddkr:|S|dd!}d}t|�}g}x9d|koy|knr�tj||�}tj||�}|r�|r�|j||�Pnd}}|r�|jd�}n|r�|jd�}n|rN|s||krN|j|||!�|j||d�|d}qb|j|||!�|jtt||d|d!d���|d}qbWt|�S(NiiRi����iii(	tlent
_OctalPatttsearcht
_QuotePatttappendtstartRtintR(RtitntrestOmatchtQmatchtjtk((s/usr/lib64/python2.7/Cookie.pyt_unquoteJs6 


+tMontTuetWedtThutFritSattSuntJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDecic	Csoddlm}m}|�}|||�\	}}}}	}
}}}
}d|||||||	|
|fS(Ni����(tgmtimettimes#%s, %02d %3s %4d %02d:%02d:%02d GMT(R>R=(tfuturetweekdaynamet	monthnameR=R>tnowtyeartmonthtdaythhtmmtsstwdtytz((s/usr/lib64/python2.7/Cookie.pyt_getdate�s
	+tMorselcBs�eZidd6dd6dd6dd6dd6d	d	6d
d
6dd6Zd	d
hZd
�Zd�Zd�Zeee	j
d�Zddd�Z
e
Zd�Zdd�Zdd�ZRS(texpirestPathtpathtCommenttcommenttDomaintdomainsMax-Agesmax-agetsecurethttponlytVersiontversioncCsBd|_|_|_x$|jD]}tj||d�q!WdS(NR(tNonetkeytvaluetcoded_valuet	_reservedtdictt__setitem__(tselftK((s/usr/lib64/python2.7/Cookie.pyt__init__�scCsE|j�}||jkr.td|��ntj|||�dS(NsInvalid Attribute %s(tlowerR]RR^R_(R`RatV((s/usr/lib64/python2.7/Cookie.pyR_�scCs|j�|jkS(N(RcR](R`Ra((s/usr/lib64/python2.7/Cookie.pyt
isReservedKey�scCsr|j�|jkr(td|��nd||||�krStd|��n||_||_||_dS(Ns!Attempt to set a reserved key: %sRsIllegal key value: %s(RcR]RRZR[R\(R`RZtvalt	coded_valRRR((s/usr/lib64/python2.7/Cookie.pytset�s		sSet-Cookie:cCsd||j|�fS(Ns%s %s(tOutputString(R`tattrstheader((s/usr/lib64/python2.7/Cookie.pytoutput�scCs#d|jj|jt|j�fS(Ns<%s: %s=%s>(t	__class__R
RZtreprR[(R`((s/usr/lib64/python2.7/Cookie.pyt__repr__�scCs d|j|�jdd�fS(Ns�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        Rs\"(Ritreplace(R`Rj((s/usr/lib64/python2.7/Cookie.pyt	js_output�scCs�g}|j}|d|j|jf�|dkrA|j}n|j�}|j�x)|D]!\}}|dkr|q^n||kr�q^n|dkr�t|�td�kr�|d|j|t|�f�q^|dkrt|�td�kr|d|j||f�q^|dkr>|t	|j|��q^|dkrd|t	|j|��q^|d|j||f�q^Wt
|�S(	Ns%s=%sRRNismax-ages%s=%dRURV(RRZR\RYR]titemstsortttypeRLRt_semispacejoin(R`RjtresulttRARrRaRd((s/usr/lib64/python2.7/Cookie.pyRi�s,	
$$$N(R
RR]t_flagsRbR_Ret_LegalCharst_idmaptstringRRhRYRlt__str__RoRqRi(((s/usr/lib64/python2.7/Cookie.pyRM�s&

					s,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=s\[\]s(?x)\s*(?P<key>[sN]+?)(\s*=\s*(?P<val>"(?:[^\\"]|\\.)*"|\w{3},\s[\s\w\d-]{9,11}\s[\d:]{8}\sGMT|[s]*))?\s*(\s+|;|$)cBszeZd�Zd�Zdd�Zd�Zd�Zdddd�ZeZ	d�Z
dd	�Zd
�Ze
d�ZRS(
cCs
||fS(s
real_value, coded_value = value_decode(STRING)
        Called prior to setting a cookie's value from the network
        representation.  The VALUE is the value read from HTTP
        header.
        Override this function to modify the behavior of cookies.
        ((R`Rf((s/usr/lib64/python2.7/Cookie.pytvalue_decode2scCst|�}||fS(s�real_value, coded_value = value_encode(VALUE)
        Called prior to setting a cookie's value from the dictionary
        representation.  The VALUE is the value being assigned.
        Override this function to modify the behavior of cookies.
        (R(R`Rftstrval((s/usr/lib64/python2.7/Cookie.pytvalue_encode<scCs|r|j|�ndS(N(tload(R`tinput((s/usr/lib64/python2.7/Cookie.pyRbFscCs?|j|t��}|j|||�tj|||�dS(s+Private method for setting a cookie's valueN(RRMRhR^R_(R`RZt
real_valueR\tM((s/usr/lib64/python2.7/Cookie.pyt__setJscCsQt|t�r%tj|||�n(|j|�\}}|j|||�dS(sDictionary style assignment.N(t
isinstanceRMR^R_Rt_BaseCookie__set(R`RZR[trvaltcval((s/usr/lib64/python2.7/Cookie.pyR_QssSet-Cookie:s
cCsYg}|j�}|j�x-|D]%\}}|j|j||��q#W|j|�S(s"Return a string suitable for HTTP.(RrRsRRltjoin(R`RjRktsepRvRrRaRd((s/usr/lib64/python2.7/Cookie.pyRl[s
cCsmg}|j�}|j�x4|D],\}}|jd|t|j�f�q#Wd|jjt|�fS(Ns%s=%ss<%s: %s>(RrRsRRnR[RmR
t
_spacejoin(R`tLRrRaRd((s/usr/lib64/python2.7/Cookie.pyRogs
$cCsSg}|j�}|j�x*|D]"\}}|j|j|��q#Wt|�S(s(Return a string suitable for JavaScript.(RrRsRRqR(R`RjRvRrRaRd((s/usr/lib64/python2.7/Cookie.pyRqos
cCsSt|�td�kr(|j|�n'x$|j�D]\}}|||<q5WdS(s�Load cookies from a string (presumably HTTP_COOKIE) or
        from a dictionary.  Loading cookies from a dictionary 'd'
        is equivalent to calling:
            map(Cookie.__setitem__, d.keys(), d.values())
        RN(Rtt_BaseCookie__ParseStringRr(R`trawdataR(tv((s/usr/lib64/python2.7/Cookie.pyR�ys
cCsVd}t|�}d}x7d|ko2|knrQ|j||�}|sSPn|jd�|jd�}}|jd�}|ddkr�|rN|||d<qNq|j�tjkr
|rN|dkr�|j�tjkrt	||<qq
t
|�||<qNq|dk	r|j|�\}	}
|j||	|
�||}qqWdS(NiRZRft$i(
RRYtmatchtgrouptendRcRMR]RxtTrueR)R}R�(R`RtpattR"R#R�R�RaRdR�R�((s/usr/lib64/python2.7/Cookie.pyt
__ParseString�s,N(R
RR}RRYRbR�R_RlR|RoRqR�t_CookiePatternR�(((s/usr/lib64/python2.7/Cookie.pyR.s	
	
		

	
	cBs eZdZd�Zd�ZRS(s
SimpleCookie
    SimpleCookie supports strings as cookie values.  When setting
    the value using the dictionary assignment notation, SimpleCookie
    calls the builtin str() to convert the value to a string.  Values
    received from HTTP are kept as strings.
    cCst|�|fS(N(R)(R`Rf((s/usr/lib64/python2.7/Cookie.pyR}�scCst|�}|t|�fS(N(RR(R`RfR~((s/usr/lib64/python2.7/Cookie.pyR�s(R
Rt__doc__R}R(((s/usr/lib64/python2.7/Cookie.pyR�s	cBs,eZdZdd�Zd�Zd�ZRS(s.SerialCookie
    SerialCookie supports arbitrary objects as cookie values. All
    values are serialized (using cPickle) before being sent to the
    client.  All incoming values are assumed to be valid Pickle
    representations.  IF AN INCOMING VALUE IS NOT IN A VALID PICKLE
    FORMAT, THEN AN EXCEPTION WILL BE RAISED.

    Note: Large cookie values add overhead because they must be
    retransmitted on every HTTP transaction.

    Note: HTTP has a 2k limit on the size of a cookie.  This class
    does not check for this limit, so be careful!!!
    cCs$tjdt�tj||�dS(Ns-SerialCookie class is insecure; do not use it(twarningstwarntDeprecationWarningRRb(R`R�((s/usr/lib64/python2.7/Cookie.pyRb�s	cCstt|��|fS(N(RR)(R`Rf((s/usr/lib64/python2.7/Cookie.pyR}�scCs|tt|��fS(N(RR(R`Rf((s/usr/lib64/python2.7/Cookie.pyR�sN(R
RR�RYRbR}R(((s/usr/lib64/python2.7/Cookie.pyR�s
	cBs,eZdZdd�Zd�Zd�ZRS(s�SmartCookie
    SmartCookie supports arbitrary objects as cookie values.  If the
    object is a string, then it is quoted.  If the object is not a
    string, however, then SmartCookie will use cPickle to serialize
    the object into a string representation.

    Note: Large cookie values add overhead because they must be
    retransmitted on every HTTP transaction.

    Note: HTTP has a 2k limit on the size of a cookie.  This class
    does not check for this limit, so be careful!!!
    cCs$tjdt�tj||�dS(Ns3Cookie/SmartCookie class is insecure; do not use it(R�R�R�RRb(R`R�((s/usr/lib64/python2.7/Cookie.pyRb�s	cCs5t|�}yt|�|fSWn||fSXdS(N(R)R(R`RfR~((s/usr/lib64/python2.7/Cookie.pyR}�s
cCsBt|�td�kr(|t|�fS|tt|��fSdS(NR(RtRR(R`Rf((s/usr/lib64/python2.7/Cookie.pyR�sN(R
RR�RYRbR}R(((s/usr/lib64/python2.7/Cookie.pyR�s	cCs%ddl}ddl}|j|�S(Ni����(tdoctestRttestmod(R�R((s/usr/lib64/python2.7/Cookie.pyt_test�st__main__(,R�R{tcPickleRRtImportErrortpickletreR�t__all__R�RRuR�t	ExceptionRt
ascii_letterstdigitsRyRtxrangeRzRRtcompileRRR)t_weekdaynameRYt
_monthnameRLR^RMt_LegalKeyCharst_LegalValueCharsR�RRRRRR�R
(((s/usr/lib64/python2.7/Cookie.pyt<module>�s�
				2~

|$	

Zerion Mini Shell 1.0