
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
U
    'â7`ƒ/  ã                   @   sì   d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
mZ d dlmZmZmZmZmZmZmZmZmZmZ d dlmZ ddlmZ ddlmZmZ dd	lmZm Z  d
Z!ee"df Z#G dd„ deƒZ$G dd„ deƒZ%dS )é    N)Údefaultdict)Ú
BaseCookieÚMorselÚSimpleCookie)
ÚDefaultDictÚDictÚIterableÚIteratorÚMappingÚOptionalÚSetÚTupleÚUnionÚcast)ÚURLé   )ÚAbstractCookieJar)Úis_ip_addressÚnext_whole_second)ÚLooseCookiesÚPathLike)Ú	CookieJarÚDummyCookieJarúMorsel[str]c                       sx  e Zd ZdZe d¡Ze d¡Ze d¡Ze dej	¡Z
e d¡Zejjjejjd�Zej d¡Zd	d
ddœeeeej ddœ‡ fdd„Zeddœdd„Zeddœdd„Zddœdd„Zddœdd„Zedœdd„Zddœdd„Z eje!e!ddœd d!„Z"e#ƒ fe$e#dd"œd#d$„Z%e#ƒ fe#e&d% d&œd'd(„Z'e(e!e!ed)œd*d+„ƒZ)e(e!e!ed,œd-d.„ƒZ*e+e!eej d/œd0d1„ƒZ,‡  Z-S )2r   z/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})©ÚtzinfoiÿÿÿFTN)ÚunsafeÚquote_cookieÚloop)r   r   r   Úreturnc                   sr   t ƒ j|d� ttƒ| _tƒ | _|| _|| _t	ƒ | _
i | _| j| _z| j ¡  W n tk
rl   | j| _Y nX d S ©N©r   )ÚsuperÚ__init__r   r   Ú_cookiesÚsetÚ_host_only_cookiesÚ_unsafeÚ_quote_cookier   Ú_next_expirationÚ_expirationsÚMAX_TIMEÚ	_max_timeÚ	timestampÚOverflowErrorÚMAX_32BIT_TIME)Úselfr   r   r   ©Ú	__class__© úD/opt/alt/python38/lib64/python3.8/site-packages/aiohttp/cookiejar.pyr#   9   s    ÿzCookieJar.__init__)Ú	file_pathr   c              	   C   s8   t  |¡}|jdd��}t | j|tj¡ W 5 Q R X d S )NÚwb©Úmode)ÚpathlibÚPathÚopenÚpickleÚdumpr$   ZHIGHEST_PROTOCOL©r0   r5   Úfr3   r3   r4   ÚsaveP   s    
zCookieJar.savec              	   C   s2   t  |¡}|jdd��}t |¡| _W 5 Q R X d S )NÚrbr7   )r9   r:   r;   r<   Úloadr$   r>   r3   r3   r4   rB   U   s    
zCookieJar.load©r   c                 C   s*   | j  ¡  | j ¡  tƒ | _| j ¡  d S ©N)r$   Úclearr&   r   r)   r*   ©r0   r3   r3   r4   rE   Z   s    

zCookieJar.clearúIterator[Morsel[str]]c                 c   s*   |   ¡  | j ¡ D ]}| ¡ E d H  qd S rD   )Ú_do_expirationr$   Úvalues)r0   Úvalr3   r3   r4   Ú__iter__`   s    zCookieJar.__iter__c                 C   s   t dd„ | D ƒƒS )Nc                 s   s   | ]
}d V  qdS )r   Nr3   )Ú.0Úir3   r3   r4   Ú	<genexpr>f   s     z$CookieJar.__len__.<locals>.<genexpr>)ÚsumrF   r3   r3   r4   Ú__len__e   s    zCookieJar.__len__c           
      C   sæ   t j  t jj¡}| j|krd S | js(d S | j}g }| j}| j}| ¡ D ]N\\}}}||krŠ||  	|d ¡ | 
||f¡ | j ||f¡ qFt||ƒ}qF|D ]
}	||	= qšz|jdd�t jdd� | _W n tk
rà   | j| _Y nX d S )Nr   )Úmicrosecondr   ©Úseconds)ÚdatetimeÚnowÚtimezoneÚutcr)   r*   r,   r$   ÚitemsÚpopÚappendr&   ÚdiscardÚminÚreplaceÚ	timedeltar.   )
r0   rU   Znext_expirationZto_delÚcookiesZexpirationsÚdomainÚnameÚwhenÚkeyr3   r3   r4   rH   h   s2    
ÿ
þ
zCookieJar._do_expiration)rb   r`   ra   r   c                 C   s    t | j|ƒ| _|| j||f< d S rD   )r\   r)   r*   )r0   rb   r`   ra   r3   r3   r4   Ú_expire_cookieƒ   s    zCookieJar._expire_cookie©r_   Úresponse_urlr   c              	   C   sò  |j }| jst|ƒrdS t|tƒr*| ¡ }|D �]´\}}t|tƒsXtƒ }|||< || }|d }| d¡rtd}|d= |sœ|dk	rœ| j	 
||f¡ | }|d< | d¡rº|dd… }||d< |rÌ|  ||¡sÌq.|d }|rä| d¡�s|j}| d¡súd}nd|d| d¡…  }||d< |d }	|	�r zXt|	ƒ}
z tj tjj¡tj|
d	� }W n tk
�rl   | j}Y nX |  |||¡ W n tk
�rœ   d|d< Y nX n6|d
 }|�rÖ|  |¡}|�rÎ|  |||¡ nd|d
< || j| |< q.|  ¡  dS )zUpdate cookies.Nr`   Ú.Ú r   Úpathú/zmax-agerR   Úexpires)Úraw_hostr'   r   Ú
isinstancer
   rX   r   r   Úendswithr&   ÚaddÚ
startswithÚ_is_domain_matchri   ÚrfindÚintrT   rU   rV   rW   r^   r.   r,   rd   Ú
ValueErrorÚ_parse_dater$   rH   )r0   r_   rf   Úhostnamera   ÚcookieÚtmpr`   ri   Zmax_ageZdelta_secondsZmax_age_expirationrk   Zexpire_timer3   r3   r4   Úupdate_cookies‡   sh    




ÿ
þ
zCookieJar.update_cookies)úBaseCookie[str]zSimpleCookie[str]©Úrequest_urlr   c           	      C   sî   |   ¡  t|ƒ}| jrtƒ ntƒ }|jp*d}|jdk}| D ]®}|j}|d }|s\|j||< q:| j	slt
|ƒrlq:||f| jkr†||kr”q:n|  ||¡s”q:|  |j|d ¡s¨q:|r¶|d r¶q:td| |jtƒ ¡ƒ}| |j|j|j¡ |||< q:|S )z8Returns this jar's cookies filtered by their attributes.rh   )ÚhttpsÚwssr`   ri   Zsecurer   )rH   r   r(   r   r   rl   Úschemerc   Úvaluer'   r   r&   rq   Ú_is_path_matchri   r   Úgetr   r%   Zcoded_value)	r0   r|   Úfilteredrv   Zis_not_securerw   ra   r`   Zmrsl_valr3   r3   r4   Úfilter_cookiesÔ   s6    ÿ



zCookieJar.filter_cookies)r`   rv   r   c                 C   sD   || krdS |  | ¡sdS |dt| ƒ … }|  d¡s:dS t|ƒ S )z0Implements domain matching adhering to RFC 6265.TFNrg   )rn   Úlenr   )r`   rv   Únon_matchingr3   r3   r4   rq      s    

zCookieJar._is_domain_match)Úreq_pathÚcookie_pathr   c                 C   sP   |   d¡sd} | |krdS |   |¡s(dS | d¡r6dS | t|ƒd… }|  d¡S )z.Implements path matching adhering to RFC 6265.rj   TFN)rp   rn   r…   )r‡   rˆ   r†   r3   r3   r4   r�     s    


zCookieJar._is_path_match)Údate_strr   c              	   C   s¼  |sdS d}d}d}d}d } }}d}	d}
d}| j  |¡D ]¸}| d¡}|s|| j |¡}|r|d}dd„ | ¡ D ƒ\}}}q<|s¢| j |¡}|r¢d}t| ¡ ƒ}	q<|sÐ| j |¡}|rÐd}|j	dk	sÈt
‚|j	}
q<|s<| j |¡}|r<d}t| ¡ ƒ}q<d|  k�rd	k�rn n
|d
7 }n$d|  k�r4dk�r@n n|d7 }d||||fk�rVdS d|	  k�rndk�stn dS |dk �sœ|dk�sœ|dk�sœ|dk�r dS tj||
|	|||tjjd�S )z4Implements date string parsing adhering to RFC 6265.NFr   ÚtokenTc                 S   s   g | ]}t |ƒ‘qS r3   )rs   )rL   Úsr3   r3   r4   Ú
<listcomp>;  s     z)CookieJar._parse_date.<locals>.<listcomp>éF   éc   il  éE   iÐ  r   é   iA  é   é;   r   )ÚDATE_TOKENS_REÚfinditerÚgroupÚDATE_HMS_TIME_REÚmatchÚgroupsÚDATE_DAY_OF_MONTH_RErs   ÚDATE_MONTH_REÚ	lastindexÚAssertionErrorÚDATE_YEAR_RErT   rV   rW   )Úclsr‰   Z
found_timeZ	found_dayZfound_monthZ
found_yearÚhourÚminuteÚsecondÚdayÚmonthÚyearZtoken_matchrŠ   Z
time_matchZ	day_matchZmonth_matchZ
year_matchr3   r3   r4   ru   #  sn    

(      ÿzCookieJar._parse_date).Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚreÚcompiler“   r–   r™   ÚIrš   r�   rT   Úmaxr]   rV   rW   r+   Úutcfromtimestampr/   Úboolr   ÚasyncioÚAbstractEventLoopr#   r   r@   rB   rE   rK   rs   rP   rH   Ústrrd   r   r   ry   r   r„   Ústaticmethodrq   r�   Úclassmethodru   Ú__classcell__r3   r3   r1   r4   r   "   sR   ÿ

þ
ûúNÿþ,r   c                       s†   e Zd ZdZddœeej ddœ‡ fdd„Zddœd	d
„Ze	dœdd„Z
ddœdd„Zeƒ feeddœdd„Zeddœdd„Z‡  ZS )r   zxImplements a dummy cookie storage.

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

    Nr!   )r   r   c                   s   t ƒ j|d� d S r    )r"   r#   )r0   r   r1   r3   r4   r#   m  s    zDummyCookieJar.__init__rG   rC   c                 c   s   d S rD   r3   rF   r3   r3   r4   rK   p  s    zDummyCookieJar.__iter__c                 C   s   dS )Nr   r3   rF   r3   r3   r4   rP   t  s    zDummyCookieJar.__len__c                 C   s   d S rD   r3   rF   r3   r3   r4   rE   w  s    zDummyCookieJar.clearre   c                 C   s   d S rD   r3   )r0   r_   rf   r3   r3   r4   ry   z  s    zDummyCookieJar.update_cookiesrz   r{   c                 C   s   t ƒ S rD   )r   )r0   r|   r3   r3   r4   r„   }  s    zDummyCookieJar.filter_cookies)r¥   r¦   r§   r¨   r   r¯   r°   r#   rK   rs   rP   rE   r   r   ry   r„   r´   r3   r3   r1   r4   r   f  s    r   )&r¯   rT   Úosr9   r<   r©   Úcollectionsr   Zhttp.cookiesr   r   r   Útypingr   r   r   r	   r
   r   r   r   r   r   Zyarlr   Úabcr   Zhelpersr   r   Ztypedefsr   r   Ú__all__r±   Z
CookieItemr   r   r3   r3   r3   r4   Ú<module>   s$   0  F