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



Z'@sddlZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZddl
mZddlmZdd	lmZd
dfZGdd
d
eZGd
ddeZdS)N)defaultdict)Mapping)MorselSimpleCookie)ceil)URL)AbstractCookieJar)
is_ip_address	CookieJarDummyCookieJarcs9eZdZdZejdZejdZejdZejdej	Z
ejdZdZdd	d
dfdd
Z
ddZddZddZddZddZddZddZeddZeddZed d!Zed"d#Zed$d%ZS)&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@ÐAunsafeFloopNcs\tjd|tt|_t|_||_t|j	j
|_i|_dS)Nr)
super__init__rr_cookiesset_host_only_cookies_unsafer_looptime_next_expiration_expirations)selfr
r)	__class__
/cookiejar.pyr%s	zCookieJar.__init__cCsHtj|}|jdd }tj|j|tjWdQRXdS)Nmodewb)pathlibPathopenpickledumprHIGHEST_PROTOCOL)r	file_pathfrrrsave-szCookieJar.savec	CsAtj|}|jdd}tj||_WdQRXdS)Nrrb)rr r!r"loadr)rr%r&rrrr)2szCookieJar.loadcCsC|jj|jjt|jj|_|jjdS)N)rclearrrrrrr)rrrrr*7s

zCookieJar.clearccs7|jx&|jjD]}|jEdHqWdS)N)_do_expirationrvalues)rvalrrr__iter__=s
zCookieJar.__iter__cCstdd|DS)Ncss|]}dVqdS)rNr).0irrr	<genexpr>Csz$CookieJar.__len__.<locals>.<genexpr>)sum)rrrr__len__BszCookieJar.__len__c
Cs|jj}|j|kr"dS|js/dS|j}g}|j}|j}x{|jD]m\\}}}||kr||j|d|j||f|j	j
||fq]t||}q]Wx|D]
}	||	=qWt||_dS)N)
rrrrMAX_TIMEritemspopappendrdiscardminr)
rZnowZnext_expirationZto_delcookiesZexpirationsdomainnamewhenkeyrrrr+Es$				
zCookieJar._do_expirationcCs,t|j||_||j||f<dS)N)r9rr)rr=r;r<rrr_expire_cookie[szCookieJar._expire_cookiec
CsX|j}|jr#t|r#dSt|tr>|j}x	|D]\}}t|ts}t}|||<||}|d}|jdrd}|d=|r|dk	r|j	j
||f|}|d<|jdr|dd}||d<|r|j||rqE|d}|s@|jdr|j
}|jdsad}nd|d|jd}||d<|d}	|	ry0t|	}
|j|jj|
||Wq5tk
rd|d<Yq5XnK|d	}|r5|j|}|r+|j|j||n
d|d	<||j||<qEW|jdS)
zUpdate cookies.Nr;.rpath/zmax-ageexpires)raw_hostrr

isinstancerr5rrendswithradd
startswith_is_domain_matchrBrfindintr?rr
ValueError_parse_dateZ	timestamprr+)
rr:response_urlhostnamer<cookietmpr;rBZmax_ageZ
delta_secondsrDZexpire_timerrrupdate_cookies_s\		




		





zCookieJar.update_cookiesc	Cs=|jt|}t}|jp+d}|jdk}x|D]}|j}|d}|ss|j||<qD|jrt|rqD||f|j	kr||krqDn|j
||sqD|j|j|dsqD|r|drqD|j
|jt}|j|j|j|j|||<qDW|S)z8Returns this jar's cookies filtered by their attributes.rAhttpswssr;rBZsecure)rTrU)r+rrrEschemer>valuerr
rrJ_is_path_matchrBgetrrZcoded_value)	rrequest_urlZfilteredrPZ
is_not_securerQr<r;Zmrsl_valrrrfilter_cookiess4
	
	

zCookieJar.filter_cookiescCsX||krdS|j|s#dS|dt|}|jdsMdSt|S)z0Implements domain matching adhering to RFC 6265.TFNr@)rGlenr
)r;rPnon_matchingrrrrJszCookieJar._is_domain_matchcCsn|jdsd}||kr%dS|j|s8dS|jdrKdS|t|d}|jdS)z.Implements path matching adhering to RFC 6265.rCTFN)rIrGr\)Zreq_pathZcookie_pathr]rrrrXszCookieJar._is_path_matchc	Cs=|s
dSd}d}d}d}d}}}d}	d}
d}x|jj|D]}|jd}
|s|jj|
}|rd}dd|jD\}}}qU|s|jj|
}|rd}t|j}	qU|s|jj|
}|rd}|j	}
qU|sU|j
j|
}|rUd}t|j}qUWd|komd	knr|d
7}n&d|kodknr|d7}d||||fkrdSd
|	kodknsdS|dks|dks|dks|dkrdStj||
|	|||dtjj
S)z4Implements date string parsing adhering to RFC 6265.NFrtokenTcSsg|]}t|qSr)rL)r/srrr
<listcomp>s	z)CookieJar._parse_date.<locals>.<listcomp>FcilEiriA;Ztzinfo)DATE_TOKENS_REfinditergroupDATE_HMS_TIME_REmatchgroupsDATE_DAY_OF_MONTH_RErL
DATE_MONTH_RE	lastindexDATE_YEAR_REdatetimetimezoneZutc)clsZdate_strZ
found_timeZ	found_dayZfound_monthZ
found_yearZhourZminutesecondZdayZmonthZyearZtoken_matchr^Z
time_matchZ	day_matchZmonth_matchZ
year_matchrrrrNs`"	

0zCookieJar._parse_date)__name__
__module____qualname____doc__recompilergrjrmIrnrpr4rr'r)r*r.r3r+r?rrSr[staticmethodrJrXclassmethodrNrr)rrrs,		I(csmeZdZdZddfddZddZdd	Zd
dZddd
ZddZ	S)rzxImplements a dummy cookie storage.

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

    rNcstjd|dS)Nr)rr)rr)rrrr=szDummyCookieJar.__init__ccsdS)Nr)rrrrr.@szDummyCookieJar.__iter__cCsdS)Nrr)rrrrr3DszDummyCookieJar.__len__cCsdS)Nr)rrrrr*GszDummyCookieJar.clearcCsdS)Nr)rr:rOrrrrSJszDummyCookieJar.update_cookiescCsdS)Nr)rrZrrrr[MszDummyCookieJar.filter_cookies)
rurvrwrxrr.r3r*rSr[rr)rrr6s)rqrr"rycollectionsrcollections.abcrZhttp.cookiesrrmathrZyarlrabcr	Zhelpersr
__all__rrrrrr<module>s$
Back to Directory File Manager