Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/webob/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/webob/__pycache__/cookies.cpython-37.pyc

B

��?Oz*�@slddlZddlmZmZmZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
dgZe�ZGdd�dej�ZGdd�de�Zdd	�Zd
d�Zdd
�fdd�Zdd�Zdd�ZGdd�de�Zddddd�Zee�Zee�Ze� dddg�dZ!dZ"d e�#e"�Z$d!Z%d"e$Z&d#Z'd$e$Z(d%e!e%e(fZ)e&e'e)Z*e�+e
e*d&��Z,e�+e
d'd&��Z-e�rfd(d
�ne.Z/ed)d*�e0d+�D��Z1e1� d,d*�e2e1�3��D��e�r�d-nd.Z4e�r�d/nd0Z5d1d2�Z6d3d4�Z7d5Z8ej9ej:e8Z;e
e;�Z<e;d6Z=ed7d*�e0d+�D��Z>e>� e?e=e=��d8e>d0<d9e>d:<e�r>ed;d*�e>�@�D��Z>e>jAZBd<ZCd=ZDd>ZEd?d@�ZFdAdB�ZGdCdD�ZHdS)E�N)�date�datetime�	timedelta)�PY3�	text_type�bytes_�text_�native_�string_types�Cookiec@s�eZdZdZdd�Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
d)dd�Zdd�Zdd�Z
dd�Zdd�Zes�dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�ZdS)*�RequestCookieszwebob._parsed_cookiescCs
||_dS)N)�_environ)�self�environ�r�>/opt/alt/python37/lib/python3.7/site-packages/webob/cookies.py�__init__szRequestCookies.__init__csh|j}|�dd�}|�|jidf�\}}||kr4|Sdd��t�fdd�t|�D��}||f||j<|S)N�HTTP_COOKIE�cSs
|�d�S)N�utf8)�decode)�brrr�<lambda>'�z'RequestCookies._cache.<locals>.<lambda>c3s"|]\}}�|��|�fVqdS)Nr)�.0�k�v)�drr�	<genexpr>(sz(RequestCookies._cache.<locals>.<genexpr>)r
�get�
_cache_key�dict�parse_cookie)r�env�header�cacheZcache_headerr)rr�_cache szRequestCookies._cachecCs*|j�d�}|dk	}|pd}tr*|�d�}t|d�}|dkrBd}ntt|d��}|d|}t�|�}d}	x�|D]l}
|
��\}}|
�	d�}
|
|krpd	}	|dkr�|d|��
d
�||d�}n|d|�|||d�}PqpW|dk	r�|r�|d|7}n|}|�rt|d�|jd<n|�r&d|jd<|	S)Nrrzlatin-1�asciizutf-8�=F�Ts ;s; )r
rr�encoder�_quote�
_rx_cookie�finditer�span�group�rstripr	)r�name�valuer$Z
had_headerZ
bytes_name�replacementZ	bytes_val�matches�found�match�start�endZ
match_namerrr�_mutate_header,s<




 
zRequestCookies._mutate_headercCsht|t�st|d��t|t�s(t|d�}yt|d�}Wntk
rRtd��YnXt|�sdtd��|S)Nzcookie name must be a stringzutf-8r'z&cookie name must be encodable to asciiz/cookie name must be valid according to RFC 2109)�
isinstancer
�	TypeErrorrrr�UnicodeEncodeError�_valid_cookie_name)rr1Zbytes_cookie_namerrrr=Rs



z!RequestCookies._valid_cookie_namecCsf|�|�}t|t�st|d��t|t�sVyt|d�}Wntk
rTt|d��YnX|�||�dS)Nzcookie value must be a stringzutf-8z,cookie value must be utf-8 binary or unicode)r=r:r
�
ValueErrorrr�UnicodeDecodeErrorr9)rr1r2rrr�__setitem___s



zRequestCookies.__setitem__cCs
|j|S)N)r&)rr1rrr�__getitem__kszRequestCookies.__getitem__NcCs|j�||�S)N)r&r)rr1�defaultrrrrnszRequestCookies.getcCs&|�|�}|�|d�}|s"t|��dS)N)r=r9�KeyError)rr1r5rrr�__delitem__qs
zRequestCookies.__delitem__cCs
|j��S)N)r&�keys)rrrrrEwszRequestCookies.keyscCs
|j��S)N)r&�values)rrrrrFzszRequestCookies.valuescCs
|j��S)N)r&�items)rrrrrG}szRequestCookies.itemscCs
|j��S)N)r&�iterkeys)rrrrrH�szRequestCookies.iterkeyscCs
|j��S)N)r&�
itervalues)rrrrrI�szRequestCookies.itervaluescCs
|j��S)N)r&�	iteritems)rrrrrJ�szRequestCookies.iteritemscCs
||jkS)N)r&)rr1rrr�__contains__�szRequestCookies.__contains__cCs
|j��S)N)r&�__iter__)rrrrrL�szRequestCookies.__iter__cCs
t|j�S)N)�lenr&)rrrr�__len__�szRequestCookies.__len__cCsd|jd<dS)Nrr)r
)rrrr�clear�szRequestCookies.clearcCsd|jfS)Nz+<RequestCookies (dict-like) with values %r>)r&)rrrr�__repr__�szRequestCookies.__repr__)N)�__name__�
__module__�__qualname__r r�propertyr&r9r=r@rArrDrErFrGrrHrIrJrKrLrNrOrPrrrrrs*&

rc@sHeZdZddd�Zdd�Zdd�ZeZdd	d
�Zdd�ZeZ	d
d�Z
dS)rNcCs|r|�|�dS)N)�load)r�inputrrrr�szCookie.__init__cCs@i}x6t|�D]*\}}|��tkr,|||<q|�||�}qWdS)N)�
_parse_cookie�lower�_c_keys�add)r�dataZmorsel�key�valrrrrU�s

zCookie.loadcCs>t|t�s|�dd�}t|�s"iSt||�}t�|||�|S)Nr'�replace)r:�bytesr*r=�Morselr!r@)rr\r]�rrrrrZ�s

z
Cookie.addTcsd��fdd�|��D��S)Nz; c3s|]}|���VqdS)N)�	serialize)r�m)�fullrrr�sz#Cookie.serialize.<locals>.<genexpr>)�joinrF)rrdr)rdrrb�szCookie.serializecCsdd�t|���D�S)NcSsg|]\}}|�qSrr)r�_rcrrr�
<listcomp>�sz!Cookie.values.<locals>.<listcomp>)�sortedrG)rrrrrF�sz
Cookie.valuescCs d|jjd�tt|����fS)Nz
<%s: [%s]>z, )�	__class__rQre�map�reprrF)rrrrrP�szCookie.__repr__)N)T)rQrRrSrrUrZr@rbrF�__str__rPrrrrr�s

ccs8tr|�d�}x$t�|�D]\}}|t|�fVqWdS)Nzlatin-1)rr*r,�findall�_unquote)r[r\r]rrrrW�s
rWcCsdd�t|�D�S)zA
    Parse cookies ignoring anything except names and values
    css"|]\}}t|�r||fVqdS)N)r=)rrrrrrr�szparse_cookie.<locals>.<genexpr>)rW)r[rrrr"�sr"cCs|S)Nr)rrrrr�rrcs ��fdd�}t�fdd�|�S)Ncs�|�|�<dS)Nr)rr)r\rbrr�fset�szcookie_property.<locals>.fsetcs|�S)Nr)r)r\rrr�rz!cookie_property.<locals>.<lambda>)rT)r\rbror)r\rbr�cookie_property�srpcCsBt|t�r(t|j|jddd�}nt|t�r:t|�}t|�S)N��<)r:r�str�seconds�days�intr)rrrr�serialize_max_age�s


rwcCs�|dkrdSt|t�r|St|t�r.|�d�St|t�rBt|d�}t|t�rXt��|}t|ttf�rn|�	�}t
�d|�}t|t
|dt|dfd�S)Nr')rtz%%s, %d-%%s-%Y %H:%M:%S GMT�r))r:r_rr*rvrr�utcnowr�	timetuple�time�strftimer�weekdays�months)rrarrr�serialize_cookie_date�s





rc@sveZdZdZdd�Zed�Zed�Zed�Zede	�Z
ede�Zed	e
�Zed
e
�Zdd�Zddd�ZeZdd�ZdS)r`)r1r2cCs<t|�st�t|t�st�||_||_|�t�t	d��dS)N)
r=�AssertionErrorr:r_r1r2�updater!�fromkeysrY)rr1r2rrrr�s
zMorsel.__init__spathsdomainscommentsexpiressmax-ageshttponlyssecurecCs(t|��d�}|tkr$t�|||�dS)Nr')rrXrYr!r@)rrrrrrr@�szMorsel.__setitem__TcCs�g}|j}||jdt|j��|r�x0tD](}||}|r,|t|dt|��q,W|d}|rp|d|�|jr~|d�|jr�|d�td�	|�d�S)Nr(sexpiressexpires=ssecuresHttpOnlys; r')
�appendr1r+r2�
_c_valkeys�
_c_renames�secure�httponlyr	re)rrd�resultrZrr�expiresrrrrb�s 
zMorsel.serializecCsd|jjt|j�t|j�fS)Nz<%s: %s=%r>)rirQr	r1r2)rrrrrPszMorsel.__repr__N)T)rQrRrS�	__slots__rrp�path�domain�commentrr�rwZmax_age�boolr�r�r@rbrlrPrrrrr`�s




r`sPathsCommentsDomainsMax-Age)spathscommentsdomainsmax-agesexpiresssecureshttponlyz
"(?:\\"|.)*?"z~!@#$%^&*()_+=-`.?|:/(){}<>'z[\w\d%s]z$\w{3},\s[\w\d-]{9,11}\s[\d:]{8}\sGMTz(%s+?)z\s*=\s*z(?:%s|\\(?:[0-3][0-7][0-7]|.))*z
(%s|%s|%s)r'z\\([0-3][0-7][0-7]|.)cCs
t|g�S)N)r_)�irrrr6rccs"|]}td|�t|�fVqdS)z%03oN)r�_bchr)rr�rrrr7sr�ccs|]}||fVqdS)Nr)rrrrrr:s�$�$�"�"cCs<|r0|d|dkr tkr0nn|dd�}t�t|�S)Nr���r))�
_b_quote_mark�_rx_unquote�sub�_ch_unquote)rrrrrn?s$rncCst|�d�S)Nr))�_ch_unquote_mapr/)rcrrrr�Esr�z!#$%&'*+-.^_`|~/z: ccs|]}t|�d|fVqdS)z\%03oN)�chr)rr�rrrrUsz\"z\\�\ccs$|]\}}t|�t|d�fVqdS)r'N)�ordr)rrrrrrr[s)�Mon�Tue�Wed�Thu�Fri�Sat�Sun)
N�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Decs                                                                                                                                                                                                                                                                cCs|�tt�S)N)�	translate�_notrans_binary�_no_escape_bytes)rrrr�_needs_quotingdsr�cCs$t|�r dd�tt|��dS|S)N�"r)r�rerj�_escape_char)rrrrr+gsr+cCs,t|t�o*t|�p(|dtkp(|��tkS)Nr)r:r_r��_b_dollar_signrXrY)r\rrrr=ms
r=)I�collectionsrrr�re�stringr{Zwebob.compatrrrrr	r
�__all__�objectZ_marker�MutableMappingrr!rrWr"rprwrr`r�rhr��setrYr�Z
_re_quotedZ_legal_special_chars�escapeZ_re_legal_charZ_re_expires_valZ_re_cookie_str_keyZ_re_cookie_str_equalZ_re_unquoted_valZ_re_cookie_str_valZ_re_cookie_str�compiler,r�r�r��ranger��listrFr�r�rnr�Z_no_escape_special_chars�
ascii_letters�digitsZ_no_escape_charsr�Z_escape_noop_charsZ_escape_map�ziprGrAr�r}r~r�r�r+r=rrrr�<module>sz 	$1