Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/aiohttp/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/aiohttp/__pycache__/cookiejar.cpython-35.opt-1.pyc



���Z�'�@s�ddlZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZddl
mZddlmZdd	lmZd
dfZGdd
�d
e�ZGd
d�de�ZdS)�N)�defaultdict)�Mapping)�Morsel�SimpleCookie)�ceil)�URL�)�AbstractCookieJar)�
is_ip_address�	CookieJar�DummyCookieJarcs9eZdZdZejd�Zejd�Zejd�Zejdej	�Z
ejd�ZdZdd	d
d�fdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Ze�dd�Ze�dd�Zed d!��Zed"d#��Zed$d%��Z�S)&rz/Implements cookie storage adhering to RFC 6265.z][\x09\x20-\x2F\x3B-\x40\x5B-\x60\x7B-\x7E]*(?P<token>[\x00-\x08\x0A-\x1F\d:a-zA-Z\x7F-\xFF]+)z(\d{1,2}):(\d{1,2}):(\d{1,2})z	(\d{1,2})zG(jan)|(feb)|(mar)|(apr)|(may)|(jun)|(jul)|(aug)|(sep)|(oct)|(nov)|(dec)z	(\d{2,4})g@��A�unsafeF�loopNcs\t�jd|�tt�|_t�|_||_t|j	j
��|_i|_dS)Nr)
�super�__init__rr�_cookies�set�_host_only_cookies�_unsafer�_loop�time�_next_expiration�_expirations)�selfr
r)�	__class__��D/opt/alt/python35/lib64/python3.5/site-packages/aiohttp/cookiejar.pyr%s	zCookieJar.__init__cCsHtj|�}|jdd�� }tj|j|tj�WdQRXdS)N�mode�wb)�pathlib�Path�open�pickle�dumprZHIGHEST_PROTOCOL)r�	file_path�frrr�save-szCookieJar.savec	CsAtj|�}|jdd��}tj|�|_WdQRXdS)Nr�rb)rr r!r"�loadr)rr$r%rrrr(2szCookieJar.loadcCsC|jj�|jj�t|jj��|_|jj�dS)N)r�clearrrrrrr)rrrrr)7s

zCookieJar.clearccs7|j�x&|jj�D]}|j�EdHqWdS)N)�_do_expirationr�values)r�valrrr�__iter__=s
zCookieJar.__iter__cCstdd�|D��S)Ncss|]}dVqdS)rNr)�.0�irrr�	<genexpr>Csz$CookieJar.__len__.<locals>.<genexpr>)�sum)rrrr�__len__BszCookieJar.__len__c
Cs�|jj�}|j|kr"dS|js/dS|j}g}|j}|j}x{|j�D]m\\}}}||kr�||j|d�|j||f�|j	j
||f�q]t||�}q]Wx|D]
}	||	=q�Wt|�|_dS)N)
rrrr�MAX_TIMEr�items�pop�appendr�discard�minr)
rZnowZnext_expirationZto_del�cookiesZexpirations�domain�name�when�keyrrrr*Es$				
zCookieJar._do_expirationcCs,t|j|�|_||j||f<dS)N)r8rr)rr<r:r;rrr�_expire_cookie[szCookieJar._expire_cookiec
CsX|j}|jr#t|�r#dSt|t�r>|j�}x	|D]\}}t|t�s}t�}|||<||}|d}|jd�r�d}|d=|r�|dk	r�|j	j
||f�|}|d<|jd�r|dd�}||d<|r|j||�rqE|d}|s@|jd�r�|j
}|jd�sad}nd|d|jd��}||d<|d}	|	r�y0t|	�}
|j|jj�|
||�Wq5tk
r�d|d<Yq5XnK|d	}|r5|j|�}|r+|j|j�||�n
d|d	<||j||<qEW|j�dS)
zUpdate cookies.Nr:�.�r�path�/zmax-age�expires)�raw_hostrr
�
isinstancerr4rr�endswithr�add�
startswith�_is_domain_matchrA�rfind�intr>rr�
ValueError�_parse_dateZ	timestamprr*)
rr9�response_url�hostnamer;�cookieZtmpr:rAZmax_ageZ
delta_secondsrCZexpire_timerrr�update_cookies_s\		




		





zCookieJar.update_cookiesc	Cs=|j�t|�}t�}|jp+d}|jdk}x�|D]�}|j}|d}|ss|j||<qD|jr�t|�r�qD||f|j	kr�||kr�qDn|j
||�s�qD|j|j|d�s�qD|r�|dr�qD|j
|jt��}|j|j|j|j�|||<qDW|S)z8Returns this jar's cookies filtered by their attributes.r@�https�wssr:rAZsecure)rRrS)r*rrrD�schemer=�valuerr
rrI�_is_path_matchrA�getrrZcoded_value)	r�request_urlZfilteredrOZ
is_not_securerPr;r:Zmrsl_valrrr�filter_cookies�s4
	
	

zCookieJar.filter_cookiescCsX||krdS|j|�s#dS|dt|��}|jd�sMdSt|�S)z0Implements domain matching adhering to RFC 6265.TFNr?)rF�lenr
)r:rO�non_matchingrrrrI�szCookieJar._is_domain_matchcCsn|jd�sd}||kr%dS|j|�s8dS|jd�rKdS|t|�d�}|jd�S)z.Implements path matching adhering to RFC 6265.rBTFN)rHrFrZ)Zreq_pathZcookie_pathr[rrrrV�szCookieJar._is_path_matchc	Cs=|s
dSd}d}d}d}d}}}d}	d}
d}x|jj|�D]�}|jd�}
|s�|jj|
�}|r�d}dd�|j�D�\}}}qU|s�|jj|
�}|r�d}t|j��}	qU|s|jj|
�}|rd}|j	}
qU|sU|j
j|
�}|rUd}t|j��}qUWd|komd	knr|d
7}n&d|ko�dknr�|d7}d||||fkr�dSd
|	ko�dkns�dS|dks|dks|dks|dkrdStj||
|	|||dtjj
�S)z4Implements date string parsing adhering to RFC 6265.NFr�tokenTcSsg|]}t|��qSr)rK)r.�srrr�
<listcomp>s	z)CookieJar._parse_date.<locals>.<listcomp>�F�cil�Ei�r�iA��;Ztzinfo)�DATE_TOKENS_RE�finditer�group�DATE_HMS_TIME_RE�match�groups�DATE_DAY_OF_MONTH_RErK�
DATE_MONTH_RE�	lastindex�DATE_YEAR_RE�datetimeZtimezoneZutc)�clsZdate_strZ
found_timeZ	found_dayZfound_monthZ
found_yearZhourZminute�secondZdayZmonthZyearZtoken_matchr\Z
time_matchZ	day_matchZmonth_matchZ
year_matchrrrrM�s`"	

0zCookieJar._parse_date)�__name__�
__module__�__qualname__�__doc__�re�compilererhrk�Irlrnr3rr&r(r)r-r2r*r>rrQrY�staticmethodrIrV�classmethodrMrr)rrrs,		I(csmeZdZdZdd�fdd�Zdd�Zdd	�Zd
d�Zddd
�Zdd�Z	�S)rzxImplements a dummy cookie storage.

    It can be used with the ClientSession when no cookie processing is needed.

    rNcst�jd|�dS)Nr)rr)rr)rrrr=szDummyCookieJar.__init__ccsdS)Nr)rrrrr-@szDummyCookieJar.__iter__cCsdS)Nrr)rrrrr2DszDummyCookieJar.__len__cCsdS)Nr)rrrrr)GszDummyCookieJar.clearcCsdS)Nr)rr9rNrrrrQJszDummyCookieJar.update_cookiescCsdS)Nr)rrXrrrrYMszDummyCookieJar.filter_cookies)
rrrsrtrurr-r2r)rQrYrr)rrr6s)rorr"rv�collectionsr�collections.abcrZhttp.cookiesrrZmathrZyarlr�abcr	Zhelpersr
�__all__rrrrrr�<module>s�$