/opt/alt/python311/lib64/python3.11/http/__pycache__
Edit: /opt/alt/python311/lib64/python3.11/http/__pycache__/cookies.cpython-311.opt-1.pyc (23590B)
h+=K d Z ddlZddlZddlZg dZdj Zdj Zdj Z G d de Z
ej ej z d z Z
e
d
z Zd e ed e eee z
D Ze ed
d ed di ej d ej e
z j Zd Z ej d Z ej d Zd Zg dZg dZdeefdZ G d de Z!dZ"e"dz Z# ej de"z dz e#z dz ej$ ej% z Z& G d d!e Z' G d" d#e' Z(dS )$a.
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.
N)CookieError
BaseCookieSimpleCookie z; c e Zd ZdS )r N)__name__
__module____qualname__ 3/opt/alt/python311/lib64/python3.11/http/cookies.pyr r s Dr
r z!#$%&'*+-.^_`|~:z
()/<=>?@[]{}c i | ]}|d |z S )z\%03or ).0ns r
r s4 J J J (Q, J J Jr
"\"\z\\z[%s]+c h | t | r| S d| t z dz S )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_Translatorstrs r _quoter s6 {mC(({
S]];///#55r
z\\[0-3][0-7][0-7]z[\\].c
j | t | dk r| S | d dk s| d dk r| S | dd } d}t | }g }d|cxk r|k rIn nEt | | }t | | }|s |s| | |d ndx}}|r| d }|r| d }|rI|r||k rA| | || | | |dz |dz }n`| | || | t
t | |dz |dz d |dz }d|cxk r|k Cn t | S )N r r ) len
_OctalPattsearch
_QuotePattappendstartchrint _nulljoin)r ir reso_matchq_matchjks r _unquoter3 s {c#hhll
1v}}B3
ad)C
ACA
C
q****1*****##C++##C++ w JJs122w
A !
a A !
a A G q1uuJJs1Q3x JJs1Q3x AAAJJs1Q3x JJs3s1Q3qs7|Q//00111AA' q****1****( S>>r
)MonTueWedThuFriSatSun)
NJanFebMarAprMayJunJulAugSepOctNovDecc ddl m}m } | } ||| z \ }}}} }
}}}
}d|| ||| || |
|fz S )Nr )gmtimetimez#%s, %02d %3s %4d %02d:%02d:%02d GMT)rI rH )futureweekdayname monthnamerH rI nowyearmonthdayhhmmsswdyzs r _getdaterW su !!!!!!!!
$&&C-3VC&L-A-A*D%b"b"a0OS)E"2D"b"EF Fr
c
e Zd ZdZdddddddd d
d Zdd
hZd Zed Zed Z ed Z
d Zd!dZd Z
ej Zd Zd Zd Zd Zd Zd Zd"dZeZd Zd!dZd!d Z eej ZdS )#MorselaC A 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.
expiresPathCommentDomainzMax-AgeSecureHttpOnlyVersionSameSite) rZ pathcommentdomainmax-agesecurehttponlyversionsamesiterf rg c | d x| _ x| _ | _ | j D ]}t | |d d S )Nr )_key_value_coded_value _reserveddict__setitem__)selfkeys r __init__zMorsel.__init__! sP 6:: :DK$"3 > , ,CT3++++ , ,r
c | j S N)rk rq s r rr z
Morsel.key) s
yr
c | j S ru )rl rv s r valuezMorsel.value- s
{r
c | j S ru )rm rv s r coded_valuezMorsel.coded_value1 s r
c | }|| j vrt d| t | || d S NzInvalid attribute )lowerrn r ro rp )rq KVs r rp zMorsel.__setitem__5 sO
GGIIDN""+;<<<q!$$$$$r
Nc | }|| j vrt d| t | || S r| )r} rn r ro
setdefault)rq rr vals r r zMorsel.setdefault; sG iikkdn$$+=>>>tS#...r
c t |t st S t | | o/| j |j k o| j |j k o| j |j k S ru )
isinstancerY NotImplementedro __eq__rl rk rm rq morsels r r z
Morsel.__eq__A sg &&)) "!!D&)) 9v},9 V[(9 !V%88 :r
c t }t || |j | j |S ru )rY ro update__dict__r s r copyzMorsel.copyK s<