Viewing File: /opt/alt/python38/lib64/python3.8/site-packages/aiohttp/__pycache__/helpers.cpython-38.pyc

U

'7`Y@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+dd	l,m-Z-dd
l.m/Z/ddl0Z0ddl1Z1ddl2m3Z3m4Z4ddl5m6Z6dd
l7m8Z8ddl9m:Z:ddl;m<Z<m=Z=ddl>m?Z?dZ@ejAdkZBejAdkZCejAdkZDeCsddlEZEeEFzddlmGZGWn"eHk
rddl5mGZGYnXde$ejIe&ddddZJeCreKedZJe)dZLe)dZMeNZOePe	jQRdZSeKejTddpdejTjUodePe	jQRd ZVd!d"eWdd#DZXd$d"eWdd%DeYd&hBZZd'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8eYd9hZ[eXeZAe[AZ\Gd:d;d;Z]Gd<d=d=ed=d>d?d@gZ^e8e'e8e$e^fdAdBdCZ_e$ejdDdEdFZ`e1jadGdGdGdHGdIdJdJZbeecebfdDdKdLZdde$ejIdMddNdOZede$ejIejIddPdQZfeePdRdSdTZge1jadGdGdGdHGdUdVdVZhejidWdXecehdYdZd[Zjdee$ece$ecd\d]d^ZkdecePececd_d`daZlGdbdcdce6ZmGdddedeeeLZnenZozddflpmnZqeSsNeqZnWneHk
rfYnXdgZrdhZseterZuejtesejvdiZweterxdjZyejtesxdjejvdiZze%ece%e{e$e*ece{fePdkdldmZ|e}e|eueyZ~e}e|ewezZe$e*ece{eefePdndodpZejdDdqdrZdadsaecdDdtduZdvdwZdxdyZdzd{ZGd|d}d}ZGd~ddeGdZGdddeZGdddeZGddde0jZGdddZdeLddddZdeddddZGddde#ecefZdS)zVarious helper functionsN)
namedtuple)suppress)ceil)Path)
TracebackType)AnyCallableDict	GeneratorGenericIterableIteratorListMappingOptionalPatternSetTupleTypeTypeVarUnioncast)quote)
getproxies)	MultiDictMultiDictProxy)ProtocolURL)hdrs)
client_loggerinternal_logger)PathLike)	BasicAuth
ChainMapProxy))r&)r&)ContextManagerzasyncio.Task[Any]loopreturncCsttj|}dd|DS)NcSsh|]}|s|qS)done).0tr.r.B/opt/alt/python38/lib64/python3.8/site-packages/aiohttp/helpers.py	<setcomp>Lszall_tasks.<locals>.<setcomp>)listasyncioTask	all_tasks)r,Ztasksr.r.r2r7Hsr7_T_SZAIOHTTP_NO_EXTENSIONSdev_modeFZPYTHONASYNCIODEBUGcCsh|]}t|qSr.chrr0ir.r.r2r3asr3cCsh|]}t|qSr.r;r=r.r.r2r3bs ()<>@,;:\"/[]?={} 	c@seZdZeddddZdS)noop)NNNr-ccs
dVdSNr.selfr.r.r2	__await__~sznoop.__await__N)__name__
__module____qualname__r
rZr.r.r.r2rU}srUcsteZdZdZdeeeddfdd
Zedeedddd	Zedd
eee	dddd
Z
edddZZS)r$z!Http basic authentication helper.latin1)loginpasswordencodingr-csB|dkrtd|dkr tdd|kr0tdt||||S)Nz"None is not allowed as login valuez%None is not allowed as password valuerIz5A ":" is not allowed in login (RFC 1945#section-11.1))
ValueErrorsuper__new__)clsr`rarb	__class__r.r2reszBasicAuth.__new__)auth_headerrbr-cCsz|dd\}}Wntk
r0tdYnX|dkrJtd|ztj|ddd|}Wntjk
rtd	YnXz|d
d\}}Wntk
rtdYnX||||dS)
z<Create a BasicAuth object from an Authorization HTTP header.rSrz%Could not parse authorization header.ZbasiczUnknown authorization method %sasciiT)ZvalidatezInvalid base64 encoding.rIzInvalid credentials.rb)	splitrclowerbase64Z	b64decodeencodedecodebinasciiError)rfrirbZ	auth_typeZencoded_credentialsZdecodedZusernamerar.r.r2rps(zBasicAuth.decoderk)urlrbr-cCs6t|tstd|jdkr dS||j|jp.d|dS)zCreate BasicAuth from url.zurl should be yarl.URL instanceNr^rk)
isinstancer	TypeErroruserra)rfrsrbr.r.r2from_urls


zBasicAuth.from_urlrVcCs0|jd|j|j}dt||jS)zEncode credentials.rIzBasic %s)r`rarorbrnZ	b64encoderp)rYZcredsr.r.r2roszBasicAuth.encode)r^r_)r_)
r[r\r]__doc__strreclassmethodrprrrwro
__classcell__r.r.rgr2r$sr$r`rarb)rsr-cCs,t|}|dkr|dfS|d|fSdSrW)r$rwZ	with_user)rsauthr.r.r2strip_auth_from_urls
r}rVc
Cstjd}|dk	rt|}nZzt}Wn4tk
r^}ztd|WYdSd}~XYnX|t	dkrrdnd}zt

t|WSt
jk
r}zt
d|W5d}~XYn:tk
r}z|s|rt
d|W5d}~XYnXdS)	zAttempt to load the netrc file from the path specified by the env-var
    NETRC or in the default location in the user's home directory.

    Returns None if it couldn't be found or fails to parse.
    ZNETRCNzHCould not resolve home directory when trying to look for .netrc file: %sZWindowsZ_netrcz.netrczCould not parse .netrc file: %szCould not read .netrc file: %s)osenvirongetrhomeRuntimeErrorr!debugplatformsystemnetrcryZNetrcParseErrorwarningOSErroris_file)Z	netrc_envZ
netrc_pathZhome_direr.r.r2netrc_from_envs,
rT)Zauto_attribsfrozenslotsc@s"eZdZUeed<eeed<dS)	ProxyInfoproxyZ
proxy_authN)r[r\r]r__annotations__rr$r.r.r.r2rs
rcCsddtD}t}dd|D}i}|D]\}}|\}}|jdkr`td|q8|r|dkrd}|jdk	r||j}|dk	r|^}	}
|	dr|	dn|	d}tt	t
|t	t
|
}t||||<q8|S)NcSs"i|]\}}|dkr|t|qS))Zhttphttpsrr0kvr.r.r2
<dictcomp>sz$proxies_from_env.<locals>.<dictcomp>cSsi|]\}}|t|qSr.)r}rr.r.r2rsrz,HTTPS proxies %s are not supported, ignoringr)ritemsrZschemer!rhostZauthenticatorsr$rryr)Z
proxy_urlsZ	netrc_objstrippedZretprotovalrr|Zauth_from_netrcZloginsrar`r.r.r2proxies_from_envs&


rzOptional[asyncio.Task[Any]]cCs"trtj|dStjj|dSdS)Nr,)PY_37r5current_taskr6rr.r.r2rsrcCsB|dkrt}|s>tjdtdd|r>tjddd|S)Nz5The object should be created within an async functionr&)
stacklevelT)Z
stack_info)	r5Zget_event_loopZ
is_runningwarningswarnDeprecationWarningZ	get_debugr"rrr.r.r2get_running_loopsr)objr-cCs$ttdd}|dk	r||SdSdS)NisasyncgenfunctionF)getattrinspect)rfuncr.r.r2r)src@s.eZdZUeed<eed<eed<ded<dS)MimeTypetypesubtypesuffixzMultiDictProxy[str]
parametersN)r[r\r]ryrr.r.r.r2r1s
r8)maxsize)mimetyper-c
Cs|stdddttdS|d}t}|ddD]R}|s@q6ttttfd|kr`|ddn|df\}}||	|	dq6|d	}|d	krd
}d|krttttf|ddn|df\}}d|krttttf|ddn|df\}}	t|||	t|dS)
aParses a MIME type into its components.

    mimetype is a MIME type string.

    Returns a MimeType object.

    Example:

    >>> parse_mimetype('text/html; charset=utf-8')
    MimeType(type='text', subtype='html', suffix='',
             parameters={'charset': 'utf-8'})

    r^)rrrrrHrNrPz "r*z*/*rL+)
rrrrlrrryaddrmstrip)
rpartsparamsitemkeyvalueZfulltypeZmtypestyperr.r.r2parse_mimetype9s@

(r)rdefaultr-cCs@t|dd}|r<t|tr<|ddkr<|ddkr<t|jS|S)NnamerrDrrE)rrtryrr)rrrr.r.r2guess_filenameis&
r)disptypequote_fieldsrr-c	Ks|rtt|kstd||}|rg}|D]f\}}|rJtt|ksZtd|||rht|dn|}||d|f|dkr2|dd|fq2dd	d
|D}d||f}|S)zSets ``Content-Disposition`` header.

    disptype is a disposition type: inline, attachment, form-data.
    Should be valid extension token (see RFC 2183)

    params is a dict with disposition params.
    z!bad content disposition type {!r}z+bad content disposition parameter {!r}={!r}r^z"%s"filenamez	filename*zutf-8''z; css|]}d|VqdS)rPN)join)r0Zpairr.r.r2	<genexpr>sz-content_disposition_header.<locals>.<genexpr>)TOKENsetrcformatrrappendr)	rrrrZlparamsrrZqvalZsparamsr.r.r2content_disposition_headerps"

rc@seZdZUeeefed<dS)_TSelf_cacheN)r[r\r]r	ryrrr.r.r.r2rs
rc@sVeZdZdZedefddddZd
eee	e
eddd	Zeedd
ddZdS)reifyaRUse as a class method decorator.  It operates almost exactly like
    the Python `@property` decorator, but it puts the result of the
    method it decorates into the instance dict after the first call,
    effectively replacing the function it decorates with an instance
    variable.  It is, in Python parlance, a data descriptor.

    .N)wrappedr-cCs||_|j|_|j|_dSrW)rrxr[r)rYrr.r.r2__init__szreify.__init__)instownerr-cCsrzFz|j|jWWStk
rB||}||j|j<|YWSXWn&tk
rl|dkrf|YSYnXdSrW)rrKeyErrorrAttributeError)rYrrrr.r.r2__get__s
z
reify.__get__)rrr-cCstddS)Nzreified property is read-only)r)rYrrr.r.r2__set__sz
reify.__set__)N)
r[r\r]rxrr8rrrrrrrr.r.r.r2rs
r)rz[^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$a^(?:(?:(?:[A-F0-9]{1,4}:){6}|(?=(?:[A-F0-9]{0,4}:){0,6}(?:[0-9]{1,3}\.){3}[0-9]{1,3}$)(([0-9A-F]{1,4}:){0,5}|:)((:[0-9A-F]{1,4}){1,5}:|:)|::(?:[A-F0-9]{1,4}:){5})(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])|(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}|(?=(?:[A-F0-9]{0,4}:){0,7}[A-F0-9]{0,4}$)(([0-9A-F]{1,4}:){1,7}|:)((:[0-9A-F]{1,4}){1,7}|:)|(?:[A-F0-9]{1,4}:){7}:|:(:[A-F0-9]{1,4}){7})$)flagsrj)regexregexbrr-cCsZ|dkrdSt|tr$t||St|tttfrBt||Std|t	|dS)NFz{} [{}] is not a str or bytes)
rtryboolmatchbytes	bytearray
memoryviewrurr)rrrr.r.r2_is_ip_addresss
r)rr-cCst|pt|SrW)is_ipv4_addressis_ipv6_address)rr.r.r2
is_ip_addresssrcCs$tjtjjjddtjddS)z8Return current time rounded up to the next whole second.r)Zmicrosecond)Zseconds)datetimenowtimezoneZutcreplaceZ	timedeltar.r.r.r2next_whole_seconds

rr^cCs\tt}|tkrXd}d}t|^}}}}}}}	}
d||	|||||||fa|atS)N)ZMonZTueZWedZThuZFriZSatZSun)
r^ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecz#%s, %02d %3s %4d %02d:%02d:%02d GMT)inttime_cached_current_datetimegmtime_cached_formatted_datetime)rZ_weekdaynameZ
_monthnameZyearZmonthZdayZhhZmmZssZwdtailr.r.r2rfc822_formatted_times 	rc	Cs:|\}}|}|dk	r6ttt||W5QRXdSrW)r	Exceptionr)inforefrobr.r.r2_weakref_handles

rcCsH|dk	rD|dkrD||}|dkr,t|}||tt||fSdSNr)rrcall_atrweakrefr)rrtimeoutr,whenr.r.r2weakref_handles
rcCs<|dk	r8|dkr8||}|dkr,t|}|||SdSr)rrr)cbrr,rr.r.r2
call_later(s
rc@s~eZdZdZejeeddddZe	de
e
dddd	Zdd
ddZeej
d
d
dZdd
ddZdd
ddZdS)
TimeoutHandlez Timeout handle N)r,rr-cCs||_||_g|_dSrW)_timeout_loop
_callbacks)rYr,rr.r.r2r3szTimeoutHandle.__init__).N)callbackargskwargsr-cOs|j|||fdSrW)rr)rYrrrr.r.r2register<szTimeoutHandle.registerrVcCs|jdSrW)rclearrXr.r.r2closeAszTimeoutHandle.closecCsL|j}|dk	rD|dkrD|j|}|dkr4t|}|j||jSdSdSr)rrrrr__call__)rYrrr.r.r2startDszTimeoutHandle.startBaseTimerContextcCs8|jdk	r.|jdkr.t|j}||j|StSdS)Nr)rTimerContextrrr	TimerNoop)rYtimerr.r.r2r
Ns

zTimeoutHandle.timerc
Cs>|jD](\}}}tt|||W5QRXq|jdSrW)rrrr)rYrrrr.r.r2rVs
zTimeoutHandle.__call__)r[r\r]rxr5AbstractEventLooprfloatrrrrrZHandlerr
rr.r.r.r2r0s

rc@seZdZdS)rN)r[r\r]r.r.r.r2r^src@s>eZdZedddZeeeeeeeddddZ	dS)r	rVcCs|SrWr.rXr.r.r2	__enter__cszTimerNoop.__enter__Nexc_typeexc_valexc_tbr-cCsdSrWr.rYrrrr.r.r2__exit__fszTimerNoop.__exit__)
r[r\r]rr
rr
BaseExceptionrrr.r.r.r2r	bs
r	c@sfeZdZdZejddddZedddZe	e
ee	ee	ee	e
d	d
dZdddd
ZdS)rz( Low resolution timeout context manager Nr+cCs||_g|_d|_dS)NF)r_tasks
_cancelled)rYr,r.r.r2rrszTimerContext.__init__rVcCsBt|jd}|dkrtd|jr2|tjd|j||S)Nr4Timeout context manager should be used inside a task)	rrrrcancelr5TimeoutErrorrrrYZtaskr.r.r2r
wszTimerContext.__enter__rcCs,|jr|j|tjkr(|jr(tjddSrW)rpopr5ZCancelledErrorrrrr.r.r2rs

zTimerContext.__exit__cCs(|js$t|jD]}|qd|_dS)NT)rrrrrr.r.r2rs
zTimerContext.timeout)r[r\r]rxr5rrrr
rrrrrrrr.r.r.r2ros

rc@seZdZejdddZdS)CeilTimeoutrVcCsh|jdk	rdt|jd|_|jdkr*td|j}|j}||}|dkrRt|}|j||j|_	|S)Nrrr)
rrrZ_taskrrrrZ_cancel_taskZ_cancel_handler)rYrZdelayrr.r.r2r
s


zCeilTimeout.__enter__N)r[r\r]
async_timeoutrr
r.r.r.r2rsrc@steZdZedddgZdZdZeZe	ddddZ
ee	dd	d
Zee
e	dddZee
edd
dZdS)HeadersMixin
_content_type
_content_dict_stored_content_typeN)rawr-cCs2||_|dkrd|_i|_nt|\|_|_dS)Nzapplication/octet-stream)r!rr cgiZparse_headerrYr"r.r.r2_parse_content_types
z HeadersMixin._parse_content_typerVcCs(|jtj}|j|kr"|||jS)z7The value of content part for Content-Type HTTP header.)_headersrr CONTENT_TYPEr!r%rr$r.r.r2content_types

zHeadersMixin.content_typecCs.|jtj}|j|kr"|||jdS)z7The value of charset part for Content-Type HTTP header.charset)r&rr r'r!r%r r$r.r.r2r)s

zHeadersMixin.charsetcCs&|jtj}|dk	rt|SdSdS)z(The value of Content-Length HTTP header.N)r&rr ZCONTENT_LENGTHr)rYcontent_lengthr.r.r2r*szHeadersMixin.content_length)r[r\r]	frozensetZATTRSrr sentinelr!ryr%propertyr(rr)rr*r.r.r.r2rs	rzasyncio.Future[_T])futresultr-cCs|s||dSrW)r/
set_result)r.r/r.r.r2r0sr0)r.excr-cCs|s||dSrW)r/
set_exception)r.r1r.r.r2r2sr2c@seZdZdZeeeefddddZddddZ	eed	d
dZ
deeedd
dZedddZ
eedddZeed	ddZedddZedddZdS)r%)_mapsN)mapsr-cCst||_dSrW)tupler3)rYr4r.r.r2rszChainMapProxy.__init__rVcCstd|jdS)Nz4Inheritance class {} from ChainMapProxy is forbidden)rurr[)rfr.r.r2__init_subclass__s
zChainMapProxy.__init_subclass__)rr-c	Cs<|jD](}z||WStk
r,YqXqt|dSrW)r3r)rYrmappingr.r.r2__getitem__s
zChainMapProxy.__getitem__)rrr-cCs||kr||S|SrWr.)rYrrr.r.r2rszChainMapProxy.getcCsttj|jSrW)lenrunionr3rXr.r.r2__len__szChainMapProxy.__len__cCs&i}t|jD]}||qt|SrW)reversedr3updateiter)rYdr7r.r.r2__iter__szChainMapProxy.__iter__cstfdd|jDS)Nc3s|]}|kVqdSrWr.)r0mrr.r2rsz-ChainMapProxy.__contains__.<locals>.<genexpr>anyr3)rYrr.rBr2__contains__szChainMapProxy.__contains__cCs
t|jSrWrCrXr.r.r2__bool__szChainMapProxy.__bool__cCsdtt|j}d|dS)Nz, zChainMapProxy(rC)rmapreprr3)rYZcontentr.r.r2__repr__
szChainMapProxy.__repr__)N)r[r\r]	__slots__rrryrrr6r8rrr;r
r@objectrrErFrIr.r.r.r2r%sr%)N)N)N)N)T)rxr5rnrqr#r	functoolsrrr~rresysrrrcollectionsr
contextlibrZmathrpathlibrtypesrtypingrrr	r
rrr
rrrrrrrrrrZurllib.parserZurllib.requestrrattrZ	multidictrrZtyping_extensionsrZyarlrr^r logr!r"Ztypedefsr#__all__version_infoZPY_36rZPY_38Zidna_sslZpatch_match_hostnamer*ImportErrorrr7rr8r9rKr,rrrZ
NO_EXTENSIONSrignore_environmentDEBUGrangeZCHARr<ZCTLZ
SEPARATORSrrUr$r}rsrryrrrrr	lru_cacherrrrrZreify_pyZ_helpersZreify_cZ
_ipv4_patternZ
_ipv6_patterncompileZ_ipv4_regex
IGNORECASEZ_ipv6_regexroZ_ipv4_regexbZ_ipv6_regexbrrpartialrrrrrrrrrrrrrrr	rrrrr0rr2r%r.r.r.r2<module>s0L



=(

/


 (	.
,,
Back to Directory File Manager