? GR0V Shell

GR0V shell

Linux in-mum-web921.main-hosting.eu 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64

Path : /lib64/python3.8/http/__pycache__/
File Upload :
Current File : //lib64/python3.8/http/__pycache__/cookies.cpython-38.opt-1.pyc

U

e5dO
@stdZddlZddlZdddgZdjZdjZdjZGd	ddeZ	ej
ejd
ZedZ
dd
eedeeee
DZeeddeddiedeejZddZedZedZddZddddddd gZdd!d"d#d$d%d&d'd(d)d*d+d,g
Zdeefd-d.ZGd/d0d0eZ d1Z!e!d2Z"ed3e!d4e"d5ej#ej$BZ%Gd6ddeZ&Gd7dde&Z'dS)8a.

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...

   >>> from http import cookies

Most of the time you start by creating a cookie.

   >>> C = cookies.SimpleCookie()

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

   >>> C = cookies.SimpleCookie()
   >>> 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 = cookies.SimpleCookie()
   >>> 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 = cookies.SimpleCookie()
   >>> 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 = cookies.SimpleCookie()
   >>> 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 = cookies.SimpleCookie()
   >>> 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 = cookies.SimpleCookie()
   >>> C["twix"] = "none for you"
   >>> C["twix"].value
   'none for you'

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 = cookies.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'

Finis.
NCookieError
BaseCookieSimpleCookiez;  c@seZdZdS)rN)__name__
__module____qualname__r
r
$/usr/lib64/python3.8/http/cookies.pyrsz!#$%&'*+-.^_`|~:z
 ()/<=>?@[]{}cCsi|]}|d|qS)z\%03or
).0nr
r
r
<dictcomp>sr"\"\z\\z[%s]+cCs*|dkst|r|Sd|tdSdS)zQuote a string for use in a cookie header.

    If the string does not need to be double-quoted, then just return the
    string.  Otherwise, surround the string in doublequotes and quote
    (with a \) special characters.
    Nr)
_is_legal_key	translate_Translatorstrr
r
r_quotesrz\\[0-3][0-7][0-7]z[\\].cCsN|dkst|dkr|S|ddks0|ddkr4|S|dd}d}t|}g}d|krf|krFnnt||}t||}|s|s|||dqFd}}|r|d}|r|d}|r|r||kr|||||||d|d}qP|||||tt||d|dd|d}qPt|S)Nrr)	len
_OctalPattsearch
_QuotePattappendstartchrint	_nulljoin)rir
resZo_matchZq_matchjkr
r
r_unquotes6


$
r+ZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc	CsRddlm}m}|}|||\	}}}}	}
}}}
}d|||||||	|
|fS)Nr)gmtimetimez#%s, %02d %3s %4d %02d:%02d:%02d GMT)r-r,)ZfutureZweekdaynameZ	monthnamer,r-ZnowZyearZmonthZdayZhhZmmZssZwdyzr
r
r_getdatesr0c
@seZdZdZdddddddd	d
d	Zdd
hZddZeddZeddZ	eddZ
ddZd2ddZddZ
ejZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd3d*d+ZeZd,d-Zd4d.d/Zd5d0d1ZdS)6MorselaCA class to hold ONE (key, value) pair.

    In a cookie, each such pair may have several attributes, so this class is
    used to keep the attributes associated with the appropriate key,value pair.
    This class also includes a coded_value attribute, which is used to hold
    the network representation of the value.
    expiresPathCommentZDomainzMax-AgeZSecureZHttpOnlyZVersionZSameSite)	r2pathcommentZdomainmax-agesecurehttponlyversionZsamesiter8r9cCs0d|_|_|_|jD]}t||dqdS)Nr)_key_value_coded_value	_reserveddict__setitem__)selfkeyr
r
r__init__ s
zMorsel.__init__cCs|jSN)r;rAr
r
rrB(sz
Morsel.keycCs|jSrD)r<rEr
r
rvalue,szMorsel.valuecCs|jSrD)r=rEr
r
rcoded_value0szMorsel.coded_valuecCs2|}||jkr td|ft|||dSNzInvalid attribute %r)lowerr>rr?r@)rAKVr
r
rr@4s
zMorsel.__setitem__NcCs.|}||jkr td|ft|||SrH)rIr>rr?
setdefault)rArBvalr
r
rrL:s
zMorsel.setdefaultcCs>t|tstSt||o<|j|jko<|j|jko<|j|jkSrD)
isinstancer1NotImplementedr?__eq__r<r;r=rAZmorselr
r
rrP@s



z
Morsel.__eq__cCs$t}t|||j|j|SrD)r1r?update__dict__rQr
r
rcopyJszMorsel.copycCsRi}t|D]0\}}|}||jkr8td|f|||<qt||dSrH)r?itemsrIr>rrR)rAvaluesdatarBrMr
r
rrRPs

z
Morsel.updatecCs||jkSrD)rIr>)rArJr
r
r
isReservedKeyYszMorsel.isReservedKeycCsH||jkrtd|ft|s2td|f||_||_||_dS)Nz Attempt to set a reserved key %rzIllegal key %r)rIr>rrr;r<r=)rArBrMZ	coded_valr
r
rset\sz
Morsel.setcCs|j|j|jdS)N)rBrFrGr;r<r=rEr
r
r__getstate__gszMorsel.__getstate__cCs"|d|_|d|_|d|_dS)NrBrFrGrZ)rAstater
r
r__setstate__ns

zMorsel.__setstate__Set-Cookie:cCsd|||fS)Nz%s %s)OutputString)rAattrsheaderr
r
routputssz
Morsel.outputcCsd|jj|fS)N<%s: %s>)	__class__rr_rEr
r
r__repr__xszMorsel.__repr__cCsd||ddS)Nz
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s";
        // end hiding -->
        </script>
        rr)r_replace)rAr`r
r
r	js_output{szMorsel.js_outputcCs$g}|j}|d|j|jf|dkr,|j}t|}|D]\}}|dkrNq<||krXq<|dkrt|tr|d|j|t|fq<|dkrt|tr|d|j||fq<|dkrt|t	r|d|j|t
|fq<||jkr|r|t	|j|q<|d|j||fq<t|S)N%s=%srr2r7z%s=%dr6)
r"rBrGr>sortedrUrNr%r0rr_flags_semispacejoin)rAr`resultr"rUrBrFr
r
rr_s,zMorsel.OutputString)N)Nr^)N)N)rrr	__doc__r>rjrCpropertyrBrFrGr@rLrPobject__ne__rTrRrXrYr[r]rb__str__rergr_r
r
r
rr1sD



	


r1z,\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=z\[\]z
    \s*                            # Optional whitespace at start of cookie
    (?P<key>                       # Start of group 'key'
    [a	]+?   # Any word of at least one letter
    )                              # End of group 'key'
    (                              # Optional group: there may not be a value.
    \s*=\s*                          # Equal Sign
    (?P<val>                         # Start of group 'val'
    "(?:[^\\"]|\\.)*"                  # Any doublequoted string
    |                                  # or
    \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT  # Special case for "expires" attr
    |                                  # or
    [a-]*      # Any word or empty string
    )                                # End of group 'val'
    )?                             # End of optional value group
    \s*                            # Any number of spaces.
    (\s+|;|$)                      # Ending either at space, semicolon, or EOS.
    c@sneZdZdZddZddZdddZd	d
ZddZdddZ	e	Z
ddZdddZddZ
efddZdS)rz'A container class for a set of Morsels.cCs||fS)a
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
rArMr
r
rvalue_decodeszBaseCookie.value_decodecCst|}||fS)zreal_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.
        rrArMZstrvalr
r
rvalue_encodeszBaseCookie.value_encodeNcCs|r||dSrD)load)rAinputr
r
rrCszBaseCookie.__init__cCs.||t}||||t|||dS)z+Private method for setting a cookie's valueN)getr1rYr?r@)rArBZ
real_valuerGMr
r
rZ__setszBaseCookie.__setcCs:t|trt|||n||\}}||||dS)zDictionary style assignment.N)rNr1r?r@ru_BaseCookie__set)rArBrFrvalcvalr
r
rr@s
zBaseCookie.__setitem__r^
cCs:g}t|}|D]\}}||||q||S)z"Return a string suitable for HTTP.)rirUr"rbjoin)rAr`raseprlrUrBrFr
r
rrbs
zBaseCookie.outputcCsJg}t|}|D] \}}|d|t|jfqd|jjt|fS)Nrhrc)rirUr"reprrFrdr
_spacejoin)rAlrUrBrFr
r
rres
zBaseCookie.__repr__cCs6g}t|}|D]\}}|||qt|S)z(Return a string suitable for JavaScript.)rirUr"rgr&)rAr`rlrUrBrFr
r
rrgs
zBaseCookie.js_outputcCs4t|tr||n|D]\}}|||<qdS)zLoad 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())
        N)rNr_BaseCookie__parse_stringrU)rAZrawdatarBrFr
r
rrv
s


zBaseCookie.loadcCshd}t|}g}d}d}d}d|kr2|krnn|||}	|	sJq|	d|	d}
}|	d}|
ddkr|s|q|||
dd|fq|
tjkr|sdS|dkr|
tjkr|||
dfqdSn|||
t	|fq|dk	r|||
|
|fd}qdSqd}|D]>\}
}
}|
|krB|||
<n|\}}||
||||
}q$dS)	NrFrrrBrM$T)rmatchgroupendr"rIr1r>rjr+rsrz)rArZpattr'r
Zparsed_itemsZmorsel_seenZTYPE_ATTRIBUTEZ
TYPE_KEYVALUErrBrFrytpr{r|r
r
rZ__parse_stringsF



zBaseCookie.__parse_string)N)Nr^r})N)rrr	rmrsrurCrzr@rbrqrergrv_CookiePatternrr
r
r
rrs		
	

c@s eZdZdZddZddZdS)rz
    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.
    cCst||fSrD)r+rrr
r
rrs\szSimpleCookie.value_decodecCst|}|t|fSrD)rrrtr
r
rru_szSimpleCookie.value_encodeN)rrr	rmrsrur
r
r
rrUs)(rmrestring__all__r~r&rkr	ExceptionrZ
ascii_lettersZdigitsZ_LegalCharsZ_UnescapedCharsrYrangemapordrrRcompileescape	fullmatchrrrr!r+Z_weekdaynameZ
_monthnamer0r?r1Z_LegalKeyCharsZ_LegalValueCharsASCIIVERBOSErrrr
r
r
r<module>'sr]


24


T1KUS90T
  root-grov@89.117.188.241:~$