ok

Mini Shell

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

U

'�7`�Y�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	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jAdkZDeC�s�ddlEZEeE�F�zddlmGZGWn"eHk
�r�ddl5mGZGYnXd�e$ejIe&dd�dd�ZJeC�reKed�ZJe)d�ZLe)d�ZMeN�ZOePe	jQ�Rd��ZSeKejTdd��pdejTjU�odePe	jQ�Rd ��ZVd!d"�eWdd#�D�ZXd$d"�eWdd%�D�eYd&�hBZZd'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8eYd9�hZ[eXeZAe[AZ\Gd:d;�d;�Z]Gd<d=�d=ed=d>d?d@g��Z^e8e'e8e$e^fdA�dBdC�Z_e$ejdD�dEdF�Z`e1jadGdGdGdH�GdIdJ�dJ��ZbeecebfdD�dKdL�Zdd�e$ejIdMd�dNdO�Zed�e$ejIejId�dPdQ�ZfeePdR�dSdT�Zge1jadGdGdGdH�GdUdV�dV��ZhejidWdX�ecehdY�dZd[��Zjd�ee$ece$ecd\�d]d^�Zkd�ecePececd_�d`da�ZlGdbdc�dce6�ZmGddde�deeeL�ZnenZozddflpmnZqeS�sNeqZnWneHk
�rfYnXdgZrdhZse�ter�Zuejtesejvdi�Zwe�ter�xdj��Zyejtes�xdj�ejvdi�Zze%ece%e{e$e*ece{fePdk�dldm�Z|e�}e|euey�Z~e�}e|ewez�Ze$e*ece{e�e�fePdn�dodp�Z�ejdD�dqdr�Z�da�dsa�ecdD�dtdu�Z�dvdw�Z�dxdy�Z�dzd{�Z�Gd|d}�d}�Z�Gd~d�deGd�Z�Gd�d��d�e��Z�Gd�d��d�e��Z�Gd�d��d�e0j��Z�Gd�d��d��Z�d�eLdd��d�d��Z�d�e�dd��d�d��Z�Gd�d��d�e#ecef�Z�dS)�zVarious helper functions�N)�
namedtuple)�suppress)�ceil)�Path)�
TracebackType)�Any�Callable�Dict�	Generator�Generic�Iterable�Iterator�List�Mapping�Optional�Pattern�Set�Tuple�Type�TypeVar�Union�cast)�quote)�
getproxies)�	MultiDict�MultiDictProxy)�Protocol��URL�)�hdrs)�
client_logger�internal_logger)�PathLike)�	BasicAuth�
ChainMapProxy)��)r&�)r&�)�ContextManagerzasyncio.Task[Any]��loop�returncCsttj�|��}dd�|D�S)NcSsh|]}|��s|�qS�)�done)�.0�tr.r.�B/opt/alt/python38/lib64/python3.8/site-packages/aiohttp/helpers.py�	<setcomp>Lszall_tasks.<locals>.<setcomp>)�list�asyncio�Task�	all_tasks)r,Ztasksr.r.r2r7Hsr7�_T�_SZAIOHTTP_NO_EXTENSIONS�dev_modeFZPYTHONASYNCIODEBUGcCsh|]}t|��qSr.��chr�r0�ir.r.r2r3asr3�cCsh|]}t|��qSr.r;r=r.r.r2r3bs� ��(�)�<�>�@�,�;�:�\�"�/�[�]�?�=�{�}� �	c@seZdZedd�dd�ZdS)�noop)NNN�r-ccs
dVdS�Nr.��selfr.r.r2�	__await__~sznoop.__await__N)�__name__�
__module__�__qualname__r
rZr.r.r.r2rU}srUcsteZdZdZdeeedd��fdd�
Zedeedd�dd	��Zedd
�eee	dd�dd
��Z
ed�dd�Z�ZS)r$z!Http basic authentication helper.��latin1)�login�password�encodingr-csB|dkrtd��|dkr td��d|kr0td��t��||||�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))�
ValueError�super�__new__)�clsr`rarb��	__class__r.r2re�szBasicAuth.__new__)�auth_headerrbr-cCs�z|�dd�\}}Wntk
r0td��YnX|��dkrJtd|��ztj|�d�dd��|�}Wntjk
r�td	��YnXz|�d
d�\}}Wntk
r�td��YnX||||d�S)
z<Create a BasicAuth object from an Authorization HTTP header.rSrz%Could not parse authorization header.ZbasiczUnknown authorization method %s�asciiT)ZvalidatezInvalid base64 encoding.rIzInvalid credentials.�rb)	�splitrc�lower�base64Z	b64decode�encode�decode�binascii�Error)rfrirbZ	auth_typeZencoded_credentialsZdecodedZusernamerar.r.r2rp�s(��zBasicAuth.decoderk)�urlrbr-cCs6t|t�std��|jdkr dS||j|jp.d|d�S)zCreate BasicAuth from url.zurl should be yarl.URL instanceNr^rk)�
isinstancer�	TypeError�userra)rfrsrbr.r.r2�from_url�s


zBasicAuth.from_urlrVcCs0|j�d|j���|j�}dt�|��|j�S)zEncode credentials.rIzBasic %s)r`rarorbrnZ	b64encoderp)rYZcredsr.r.r2ro�szBasicAuth.encode)r^r_)r_)
r[r\r]�__doc__�strre�classmethodrprrrwro�
__classcell__r.r.rgr2r$�s��r$r`rarb)rsr-cCs,t�|�}|dkr|dfS|�d�|fSdSrW)r$rwZ	with_user)rs�authr.r.r2�strip_auth_from_url�s
r}rVc
Cs�tj�d�}|dk	rt|�}nZzt��}Wn4tk
r^}zt�d|�WY�dSd}~XYnX|t�	�dkrrdnd}zt
�
t|��WSt
jk
r�}zt�
d|�W5d}~XYn:tk
r�}z|s�|��r�t�
d|�W5d}~XYnXdS)	z�Attempt 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)�os�environ�getr�home�RuntimeErrorr!�debug�platform�system�netrcryZNetrcParseError�warning�OSError�is_file)Z	netrc_envZ
netrc_pathZhome_dir�er.r.r2�netrc_from_env�s,
��r�T)Zauto_attribs�frozen�slotsc@s"eZdZUeed<eeed<dS)�	ProxyInfo�proxyZ
proxy_authN)r[r\r]r�__annotations__rr$r.r.r.r2r��s
r�cCs�dd�t���D�}t�}dd�|��D�}i}|��D]�\}}|\}}|jdkr`t�d|�q8|r�|dkr�d}|jdk	r�|�|j�}|dk	r�|�^}	}
|	dr�|	dn|	d}tt	t
|�t	t
|
��}t||�||<q8|S)NcSs"i|]\}}|dkr|t|��qS))Zhttp�httpsr�r0�k�vr.r.r2�
<dictcomp>�sz$proxies_from_env.<locals>.<dictcomp>cSsi|]\}}|t|��qSr.)r}r�r.r.r2r��sr�z,HTTPS proxies %s are not supported, ignoringr���)r�itemsr�Zschemer!r��hostZauthenticatorsr$rryr�)Z
proxy_urlsZ	netrc_obj�strippedZret�proto�valr�r|Zauth_from_netrcZloginsrar`r.r.r2�proxies_from_env�s&


r�zOptional[asyncio.Task[Any]]cCs"trtj|d�Stjj|d�SdS)N�r,)�PY_37r5�current_taskr6r�r.r.r2r�sr�cCsB|dkrt��}|��s>tjdtdd�|��r>tjddd�|S)Nz5The object should be created within an async functionr&)�
stacklevelT)Z
stack_info)	r5Zget_event_loopZ
is_running�warnings�warn�DeprecationWarningZ	get_debugr"r�r�r.r.r2�get_running_loops��r�)�objr-cCs$ttdd�}|dk	r||�SdSdS)N�isasyncgenfunctionF)�getattr�inspect)r��funcr.r.r2r�)sr�c@s.eZdZUeed<eed<eed<ded<dS)�MimeType�type�subtype�suffixzMultiDictProxy[str]�
parametersN)r[r\r]ryr�r.r.r.r2r�1s
r��8)�maxsize)�mimetyper-c
Cs|stdddtt��d�S|�d�}t�}|dd�D]R}|s@q6ttttfd|kr`|�dd�n|df�\}}|�|���	�|�	d��q6|d�	���}|d	kr�d
}d|kr�ttttf|�dd��n|df\}}d|kr�ttttf|�dd��n|df\}}	t|||	t|�d�S)
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^)r�r�r�r�rHrNrPz "r�*z*/*rL�+)
r�rrrlrrry�addrm�strip)
r��parts�params�item�key�valueZfulltypeZmtype�styper�r.r.r2�parse_mimetype9s@�

���(��r�)r��defaultr-cCs@t|dd�}|r<t|t�r<|ddkr<|ddkr<t|�jS|S)N�namerrDr�rE)r�rtryrr�)r�r�r�r.r.r2�guess_filenameis&
r�)�disptype�quote_fieldsr�r-c	Ks�|rtt|�kstd�|���|}|r�g}|��D]f\}}|rJtt|�ksZtd�||���|rht|d�n|}|�|d|f�|dkr2|�dd|f�q2d�d	d
�|D��}d�||f�}|S)z�Sets ``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>)�TOKEN�setrc�formatr�r�appendr�)	r�r�r�r�Zlparamsr�r�ZqvalZsparamsr.r.r2�content_disposition_headerps"

�r�c@seZdZUeeefed<dS)�_TSelf�_cacheN)r[r\r]r	ryrr�r.r.r.r2r��s
r�c@sVeZdZdZedefdd�dd�Zd
eee	e
ed�dd	�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)r�rxr[r�)rYr�r.r.r2�__init__�szreify.__init__)�inst�ownerr-cCsrzFz|j|jWWStk
rB|�|�}||j|j<|YWSXWn&tk
rl|dkrf|YS�YnXdSrW)r�r��KeyErrorr��AttributeError)rYr�r�r�r.r.r2�__get__�s
z
reify.__get__)r�r�r-cCstd��dS)Nzreified property is read-only)r�)rYr�r�r.r.r2�__set__�sz
reify.__set__)N)
r[r\r]rxrr8r�r�rrrr�r�r.r.r.r2r��s
r�)r�z[^(?:(?: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)�regex�regexbr�r-cCsZ|dkrdSt|t�r$t|�|��St|tttf�rBt|�|��Std�|t	|����dS)NFz{} [{}] is not a str or bytes)
rtry�bool�match�bytes�	bytearray�
memoryviewrur�r�)r�r�r�r.r.r2�_is_ip_address�s
r�)r�r-cCst|�pt|�SrW)�is_ipv4_address�is_ipv6_address)r�r.r.r2�
is_ip_address�sr�cCs$tj�tjj�jdd�tjdd�S)z8Return current time rounded up to the next whole second.r)Zmicrosecond)Zseconds)�datetime�now�timezoneZutc�replaceZ	timedeltar.r.r.r2�next_whole_second�s
�
�r�r^cCs\tt���}|tkrXd}d}t�|�^}}}}}}}	}
d||	|||||||fa|atS)N)ZMonZTueZWedZThuZFriZSatZSun)
r^ZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecz#%s, %02d %3s %4d %02d:%02d:%02d GMT)�int�time�_cached_current_datetime�gmtime�_cached_formatted_datetime)r�Z_weekdaynameZ
_monthnameZyearZmonthZdayZhhZmmZssZwd�tailr.r.r2�rfc822_formatted_time�s �	r�c	Cs:|\}}|�}|dk	r6tt��t||��W5QRXdSrW)r�	Exceptionr�)�info�refr��obr.r.r2�_weakref_handles

r�cCsH|dk	rD|dkrD|��|}|dkr,t|�}|�|tt�|�|f�SdS�Nr�)r�r�call_atr��weakrefr�)r�r��timeoutr,�whenr.r.r2�weakref_handles
r�cCs<|dk	r8|dkr8|��|}|dkr,t|�}|�||�SdSr�)r�rr�)�cbr�r,r�r.r.r2�
call_later(s
r�c@s~eZdZdZejeedd�dd�Ze	de
e
dd�dd	�Zdd
�dd�Zeej
d
�d
d�Zdd
�dd�Zdd
�dd�ZdS)�
TimeoutHandlez Timeout handle N)r,r�r-cCs||_||_g|_dSrW)�_timeout�_loop�
_callbacks)rYr,r�r.r.r2r�3s�zTimeoutHandle.__init__).N)�callback�args�kwargsr-cOs|j�|||f�dSrW)r�r�)rYr�rrr.r.r2�register<szTimeoutHandle.registerrVcCs|j��dSrW)r��clearrXr.r.r2�closeAszTimeoutHandle.closecCsL|j}|dk	rD|dkrD|j��|}|dkr4t|�}|j�||j�SdSdSr�)r�r�r�rr��__call__)rYr�r�r.r.r2�startDszTimeoutHandle.start�BaseTimerContextcCs8|jdk	r.|jdkr.t|j�}|�|j�|St�SdS)Nr)r��TimerContextr�rr��	TimerNoop)rY�timerr.r.r2r
Ns

zTimeoutHandle.timerc
Cs>|jD](\}}}tt��|||�W5QRXq|j��dSrW)r�rr�r)rYr�rrr.r.r2rVs
zTimeoutHandle.__call__)r[r\r]rxr5�AbstractEventLoopr�floatr�rrrrZHandlerr
rr.r.r.r2r�0s�
�
r�c@seZdZdS)rN)r[r\r]r.r.r.r2r^src@s>eZdZed�dd�Zeeeeeeedd�dd�Z	dS)r	rVcCs|SrWr.rXr.r.r2�	__enter__cszTimerNoop.__enter__N��exc_type�exc_val�exc_tbr-cCsdSrWr.�rYrrrr.r.r2�__exit__fszTimerNoop.__exit__)
r[r\r]rr
rr�
BaseExceptionrrr.r.r.r2r	bs
�r	c@sfeZdZdZejdd�dd�Zed�dd�Ze	e
ee	ee	ee	e
d	�d
d�Zdd�dd
�ZdS)rz( Low resolution timeout context manager Nr+cCs||_g|_d|_dS)NF)r��_tasks�
_cancelled)rYr,r.r.r2r�rszTimerContext.__init__rVcCsBt|jd�}|dkrtd��|jr2|��tjd�|j�|�|S)Nr��4Timeout context manager should be used inside a task)	r�r�r�r�cancelr5�TimeoutErrorrr��rYZtaskr.r.r2r
ws�zTimerContext.__enter__rcCs,|jr|j��|tjkr(|jr(tjd�dSrW)r�popr5ZCancelledErrorrrrr.r.r2r�s

zTimerContext.__exit__cCs(|js$t|j�D]}|��qd|_dS)NT)rr�rrrr.r.r2r��s
zTimerContext.timeout)r[r\r]rxr5rr�rr
rrrrr�rr�r.r.r.r2ros
�
rc@seZdZejd�dd�ZdS)�CeilTimeoutrVcCsh|jdk	rdt|jd�|_|jdkr*td��|j��}|j}||}|dkrRt|�}|j�||j�|_	|S)Nr�rr�)
r�r�r�Z_taskr�r�rr�Z_cancel_taskZ_cancel_handler)rYr�Zdelayr�r.r.r2r
�s

�
zCeilTimeout.__enter__N)r[r\r]�
async_timeoutr�r
r.r.r.r2r�src@steZdZedddg�ZdZdZeZe	dd�dd�Z
ee	d�d	d
��Zee
e	d�dd��Zee
ed�d
d��ZdS)�HeadersMixin�
_content_type�
_content_dict�_stored_content_typeN)�rawr-cCs2||_|dkrd|_i|_nt�|�\|_|_dS)Nzapplication/octet-stream)r!rr �cgiZparse_header�rYr"r.r.r2�_parse_content_type�s
z HeadersMixin._parse_content_typerVcCs(|j�tj�}|j|kr"|�|�|jS)z7The value of content part for Content-Type HTTP header.)�_headersr�r �CONTENT_TYPEr!r%rr$r.r.r2�content_type�s

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

zHeadersMixin.charsetcCs&|j�tj�}|dk	rt|�SdSdS)z(The value of Content-Length HTTP header.N)r&r�r ZCONTENT_LENGTHr�)rY�content_lengthr.r.r2r*�szHeadersMixin.content_length)r[r\r]�	frozensetZATTRSrr �sentinelr!ryr%�propertyr(rr)r�r*r.r.r.r2r�s	rzasyncio.Future[_T])�fut�resultr-cCs|��s|�|�dSrW)r/�
set_result)r.r/r.r.r2r0�sr0)r.�excr-cCs|��s|�|�dSrW)r/�
set_exception)r.r1r.r.r2r2�sr2c@s�eZdZdZeeeefdd�dd�Zdd�dd�Z	eed	�d
d�Z
deeed�d
d�Zed�dd�Z
eed�dd�Zeed	�dd�Zed�dd�Zed�dd�ZdS)r%)�_mapsN)�mapsr-cCst|�|_dSrW)�tupler3)rYr4r.r.r2r��szChainMapProxy.__init__rVcCstd�|j���dS)Nz4Inheritance class {} from ChainMapProxy is forbidden)rur�r[)rfr.r.r2�__init_subclass__�s
��zChainMapProxy.__init_subclass__)r�r-c	Cs<|jD](}z||WStk
r,YqXqt|��dSrW)r3r�)rYr��mappingr.r.r2�__getitem__�s
zChainMapProxy.__getitem__)r�r�r-cCs||kr||S|SrWr.)rYr�r�r.r.r2r��szChainMapProxy.getcCstt�j|j��SrW)�lenr��unionr3rXr.r.r2�__len__�szChainMapProxy.__len__cCs&i}t|j�D]}|�|�qt|�SrW)�reversedr3�update�iter)rY�dr7r.r.r2�__iter__�szChainMapProxy.__iter__cst�fdd�|jD��S)Nc3s|]}�|kVqdSrWr.)r0�m�r�r.r2r�sz-ChainMapProxy.__contains__.<locals>.<genexpr>��anyr3)rYr�r.rBr2�__contains__szChainMapProxy.__contains__cCs
t|j�SrWrCrXr.r.r2�__bool__szChainMapProxy.__bool__cCsd�tt|j��}d|�d�S)Nz, zChainMapProxy(rC)r��map�reprr3)rYZcontentr.r.r2�__repr__
szChainMapProxy.__repr__)N)r[r\r]�	__slots__rrryrr�r6r8r�r�r;r
r@�objectr�rErFrIr.r.r.r2r%�sr%)N)N)N)N)T)�rxr5rnrqr#r��	functoolsr�r�r~r��re�sysr�r�r��collectionsr�
contextlibrZmathr�pathlibr�typesr�typingrrr	r
rrr
rrrrrrrrrrZurllib.parserZurllib.requestrr�attrZ	multidictrrZtyping_extensionsrZyarlrr^r �logr!r"Ztypedefsr#�__all__�version_infoZPY_36r�ZPY_38Zidna_sslZpatch_match_hostnamer*�ImportErrorrr7r�r8r9rKr,r�rr�Z
NO_EXTENSIONSr��ignore_environment�DEBUG�rangeZCHARr<ZCTLZ
SEPARATORSr�rUr$r}r��sr�ryr�r�r�r�r��	lru_cacher�r�r�r�r�Zreify_pyZ_helpersZreify_cZ
_ipv4_patternZ
_ipv6_pattern�compileZ_ipv4_regex�
IGNORECASEZ_ipv6_regexroZ_ipv4_regexbZ_ipv6_regexbr�r��partialr�r�r�r�r�r�r�r�r�r�r�r�r�rr	rr�rrr0rr2r%r.r.r.r2�<module>s0L


��
���=(��
��
/����

�
 (	.
,,

Zerion Mini Shell 1.0