HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/yarl/__pycache__/_url.cpython-310.pyc
o

;j��@slddlZddlZddlZddlmZmZddlmZddlm	Z	m
Z
ddlmZddl
mZmZmZmZmZmZmZddlmZmZddlZddlmZmZdd	lmZd
dlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&d
dl'm(Z(m)Z)d
d
l*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0d
dl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>dddddd�Z?e@e�ZAe@d�ZBe�CdejD�ZEed�ZFejGdkr�ddl
mHZHneZHGdd�de�ZIeIjJZKGdd�de�ZLGdd�dedd�ZMdeFd eFfd!d"�ZNe
d#eOd d$fd%d&��ZPe
d#eOd d$fd'd(��ZQe
d)eOd*eOd+eeOdfd,eeOdfd-eOd.eeRdfd/eOd0eOd1eOd d$fd2d3��ZSd)eOd4eOd/eOd5eOd1eOd d$fd6d7�ZTe
eT�ZUeNGd8d$�d$��ZVd9ZWd:ZXe
eW�d;eOd eOfd<d=��aYe
eW�d-eOd eOfd>d?��aZe
eX�d-eOd@e[d eOfdAdB��a\eNdOdCdD��Z]eNd eLfdEdF��Z^eNeWeWeKeKeKdG�dHeeRdfdIeeRdfdJeeRdeIfdKeeRdeIfdLeeRdeIfd dfdMdN��Z_dS)P�N)�Mapping�Sequence)�Enum)�
_CacheInfo�	lru_cache)�
ip_address)�
TYPE_CHECKING�Any�NoReturn�	TypedDict�TypeVar�Union�overload)�SplitResult�
uses_relative)�	MultiDict�MultiDictProxy)�under_cached_property�)�USES_AUTHORITY�SplitURLType�make_netloc�query_to_pairs�split_netloc�	split_url�unsplit_result)�normalize_path�normalize_path_segments)�Query�
QueryVariable�SimpleQuery�
get_str_query�get_str_query_from_iterable�$get_str_query_from_sequence_iterable)
�FRAGMENT_QUOTER�FRAGMENT_REQUOTER�PATH_QUOTER�
PATH_REQUOTER�PATH_SAFE_UNQUOTER�
PATH_UNQUOTER�QS_UNQUOTER�QUERY_QUOTER�QUERY_REQUOTER�QUOTER�REQUOTER�UNQUOTER�human_quote�Pi��)�http�https�ws�wss�ftpa<
        # any character not in the unreserved or sub-delims sets, plus %
        # (validated with the additional check for pct-encoded sequences below)
        [^a-z0-9\-._~!$&'()*+,;=%]
    |
        # % only allowed if it is part of a pct-encoded
        # sequence of 2 hex digits.
        %(?![0-9a-f]{2})
    �_T)��)�Selfc@seZdZdZdZdS)�
UndefinedTypez4Singleton type for use with not set sentinel values.rN)�__name__�
__module__�__qualname__�__doc__�
_singleton�rBrB�=/opt/saltstack/salt/lib/python3.10/site-packages/yarl/_url.pyr<Qsr<c@s:eZdZUdZeed<eed<eed<eed<eed<dS)�	CacheInfozHost encoding cache.�idna_encode�idna_decoder�
host_validate�encode_hostN)r=r>r?r@r�__annotations__rBrBrBrCrDZs
rDc@s�eZdZUeed<ded<eed<eed<eed<eed<eed<eed	fed
<eed	fed<eed	fed<eed	fed
<eed	fed<eed	fed<eed	fed<eed	fed<eed	fed<eed	fed<eed<eed<e	e
eefed<ded<eed<eed<eed<eed<eed<eed<e
edfed <e
edfed!<ded"<eed#<eed$<eed%<eed&<e
edfed'<e
edfed(<d	S))�_InternalURLCache�_val�URL�_origin�absolute�hash�scheme�
raw_authority�	authorityN�raw_user�user�raw_password�password�raw_host�host�host_subcomponent�host_port_subcomponent�port�
explicit_port�raw_path�path�
_parsed_query�MultiDictProxy[str]�query�raw_query_string�query_string�path_qs�raw_path_qs�raw_fragment�fragment.�	raw_parts�parts�parent�raw_name�name�
raw_suffix�suffix�raw_suffixes�suffixes)r=r>r?rrI�bool�int�strr
�list�tuplerBrBrBrCrJdsJ
rJF)�total�obj�returncCs
d|_|S)NZyarl)r>)rwrBrBrC�rewrite_module�sry�url_strrLcCs�i}t|�\}}}}}|sd}n�d|vsd|vsd|vr%t|�\}}	}}
nd}}	}
|}|durA|tvr?d|�d�}t|��d}t|dd	�}d|vrQ|d
d�n||d<|
|d
<|	durw|durw|
durg|n|�d|
��}d|d<d|d<n|r}t|�n|}|	r�t|	�n|	}
t||
||
�}||d<|
|d<|r�t|�}|r�d|vr�t|�}|r�t	|�}|r�t
|�}||d<|s�|r�dn||d<||d<||d<t�t
�}||_||_||_||_||_||_|S)zParse unencoded URL.��:�@�[Nz9Invalid URL: host is required for absolute urls with the � schemeF��
validate_hostr���rWr\rSrU�.rP�/r]rbrf)rr�SCHEME_REQUIRES_HOST�
ValueError�_encode_hostr.rr'rr,r%�object�__new__rL�_scheme�_netloc�_path�_query�	_fragment�_cache)rz�cacherP�netlocr^rargrX�usernamerVr[�msgrSrU�selfrBrBrC�
encode_url�s`��

r�cCs4t�t�}t|�}|\|_|_|_|_|_i|_	|S)zParse pre-encoded URL.)
r�r�rLrr�r�r�r�r�r�)rzr��valrBrBrC�pre_encoded_url�s

r�rPrRrTrVrXr[r^rcrgc	
Cs�t�t�}	||	_|r||	_n4|r?|dur|t�|�krdn|}|dur6|dur6|dur-|n|�d|��|	_nt||||�|	_nd|	_||	_||	_	||	_
i|	_|	S)z#Build a pre-encoded URL from parts.Nr|r{)r�r�rLr�r��
DEFAULT_PORTS�getrr�r�r�r�)
rPrRrTrVrXr[r^rcrgr�rBrBrC�build_pre_encoded_url�s 

r�r�racCs2t�t�}||_||_||_||_||_i|_|S)zCreate a new URL from parts.)	r�r�rLr�r�r�r�r�r�)rPr�r^rargr�rBrBrC�from_parts_uncached�s
r�c@sLeZdZUdZeed<eed<eed<eed<eed<eed<efdd	d
�deee	de
fded
eed	fddfdd�Ze
ddd	d	dd	dd	dddd�dededeed	fdeed	fdedeed	fdedeed	fdedededdfdd��Zdefdd �Zdefd!d"�Zdefd#d$�Zdefd%d&�Zd'edefd(d)�Zdefd*d+�Zd'edefd,d-�Zd'edefd.d/�Zd'edefd0d1�Zd'edefd2d3�Zd4eddfd5d6�Zdeddfd7d8�Zdefd9d:�Z de!e	fd;d<�Z"d=ee!e#e!d	effdd	fd>d?�Z$d�d@dA�Z%defdBdC�Z&defdDdE�Z'd�dFdG�Z(e)de#fdHdI��Z*e)d�dJdK��Z+d�dLdM�Z,e)defdNdO��Z-e)defdPdQ��Z.e)defdRdS��Z/e)defdTdU��Z0e)deed	ffdVdW��Z1e)deed	ffdXdY��Z2e)deed	ffdZd[��Z3e)deed	ffd\d]��Z4e)deed	ffd^d_��Z5e)deed	ffd`da��Z6e)deed	ffdbdc��Z7e)deed	ffddde��Z8e)deed	ffdfdg��Z9e)deed	ffdhdi��Z:e)defdjdk��Z;e)defdldm��Z<e)defdndo��Z=e)de>e!eeffdpdq��Z?e)d�dsdt��Z@e)defdudv��ZAe)defdwdx��ZBe)defdydz��ZCe)defd{d|��ZDe)defd}d~��ZEe)defdd���ZFe)de!ed�ffd�d���ZGe)de!ed�ffd�d���ZHe)d�d�d���ZIe)defd�d���ZJe)defd�d���ZKe)defd�d���ZLe)defd�d���ZMe)de!ed�ffd�d���ZNe)de!ed�ffd�d���ZOd�d�d�deddfd�d��ZPdeddfd�d��ZQdeed	fddfd�d��ZRdeed	fddfd�d��ZSdeddfd�d��ZTdeed	fddfd�d��ZUdddd��deded�ed�eddf
d�d��ZVeWdeddfd�d���ZXeWd�eYddfd�d���ZXd�eZd�eZddfd�d��ZXeWdeddfd�d���Z[eWd�eYddfd�d���Z[d�eZd�eZddfd�d��Z[eWdeddfd�d���Z\eWd�eYddfd�d���Z\d�eZd�eZddfd�d��Z\d�eddfd�d��Z]deed	fddfd�d��Z^ddd��d4ed�ed�eddfd�d��Z_ddd��d�ed�ed�eddfd�d��Z`d�d�d„ZaddÜd'ededdfd�dńZbdefd�dDŽZcd	S)�rL)r�r�r�r�r�r�r�r�r�r�r�r�FN)�encoded�strictr�r�r�rxcCs�|dur	t�d�t|�tur|rt|�St|�St|�|ur!|St|�tur1|s-td��t|�St	|t�rD|r>tt|��Stt|��S|t
urat�t
�}d|_|_|_|_|_i|_|Std��)Nzstrict parameter is ignoredz$Cannot apply decoding to SplitResultr{z#Constructor parameter should be str)�warnings�warn�typersr�r�rr��
from_parts�
isinstance�	UNDEFINEDr�r�rLr�r�r�r�r�r��	TypeError)�clsr�r�r�r�rBrBrCr�\s$


zURL.__new__r{)rPrRrTrVrXr[r^rarcrgr�rPrRrTrVrXr[r^rarcrgc
Cs�|r|s
|s
|s
|rtd��|dur!t|t�s!tdt|��d���|r)|s)td��|r1|	r1td��|dusI|dusI|dusI|dusI|	dusI|
durMtd��|rUt|�pTd}	|rct||||||||	|
�	St�t	�}||_
d}
|r�t|�\}}}
}|
rt|
d	d
�nd}
n|r�t|dd
�}
nd|_
|
dur�|dur�|t�|�kr�dn|}|dur�|dur�|dur�|
n|
�d|��|_
n	t|||
|d�|_
|r�t|�n|}|r�|j
r�d|vr�t|�}|d
dkr�d}t|��||_|s�|	r�t|	�}	|	|_|
r�t|
�n|
|_i|_|S)zCreates and returns a new URLz@Can't mix "authority" with "user", "password", "host" or "port".Nz$The port is required to be int, got r�z/Can't build URL with "port" but without "host".z6Only one of "query" or "query_string" should be passedz}NoneType is illegal for "scheme", "authority", "host", "path", "query_string", and "fragment" args, use empty string instead.r{Fr�Tr|rr�zCPath in a URL with authority should start with a slash ('/') if set)r�r�rrr�r�r!r�r�r�rLr�rr�r�r�r�rr&rr�r+r�r$r�r�)r�rPrRrTrVrXr[r^rarcrgr�r�Z_hostr�rBrBrC�buildys~���

�z	URL.buildcCstd|�d���)NzInheriting a class z from URL is forbidden)r�)r�rBrBrC�__init_subclass__��zURL.__init_subclass__cCsx|js|jr|js|jrd}n|j}|j}dur.|t�|j�kr.|j}t	|j
|j|d�}n|j}t|j|||j|j�S�Nr�)
r�r�r�r�r\r�r�r�rYrrSrUr)r�r^r[rXr�rBrBrC�__str__�s�zURL.__str__cCs|jj�dt|��d�S)Nz('z'))�	__class__r=rs�r�rBrBrC�__repr__�szURL.__repr__cCst|��d�S)N�ascii)rs�encoder�rBrBrC�	__bytes__�sz
URL.__bytes__�othercCstt|�turtS|js|jrdn|j}|js|jrdn|j}|j|jko9|j|jko9||ko9|j|jko9|j|jkSr�)r�rL�NotImplementedr�r�r�r�r�)r�r�Zpath1Zpath2rBrBrC�__eq__�s
��
�
�z
URL.__eq__cCsR|j�d�}dur'|js|jrdn|j}t|j|j||j|jf�}|jd<|S)NrOr�)r�r�r�r�rOr�r�r�)r��retr^rBrBrC�__hash__�s�zURL.__hash__cCst|�turtS|j|jkS�N�r�rLr�rK�r�r�rBrBrC�__le__�z
URL.__le__cCst|�turtS|j|jkSr�r�r�rBrBrC�__lt__r�z
URL.__lt__cCst|�turtS|j|jkSr�r�r�rBrBrC�__ge__r�z
URL.__ge__cCst|�turtS|j|jkSr�r�r�rBrBrC�__gt__r�z
URL.__gt__rlcCst|t�stS|�t|�f�Sr�)r�rsr��_make_child�r�rlrBrBrC�__truediv__s
zURL.__truediv__cCs
|�|�Sr�)�update_query�r�rarBrBrC�__mod__ s
zURL.__mod__cCst|jp|jp|jp|j�Sr�)rqr�r�r�r�r�rBrBrC�__bool__#szURL.__bool__cCst�t|j�fSr�)rur�rrKr�rBrBrC�__getstate__&r�zURL.__getstate__�statecCsR|ddurt|dt�r|dd}n|^}}|\|_|_|_|_|_i|_dS)NrrrK)r��dictr�r�r�r�r�r�)r�r�r�ZunusedrBrBrC�__setstate__)s

zURL.__setstate__cCs0|j}t|j�}|\|d<|d<|d<|d<dS)z"Cache the netloc parts of the URL.rSrUrWr\N)r�rr�)r��cZ	split_locrBrBrC�
_cache_netloc5s
 zURL._cache_netloccC�|jS)z�A check for absolute URLs.

        Return True for absolute ones (having scheme or starting
        with //), False otherwise.

        Is is preferred to call the .absolute property instead
        as it is cached.
        )rNr�rBrBrC�is_absolute;s	zURL.is_absolutecCs(|j}dur|jdkS|t�|j�kS)z�A check for default port.

        Return True if port is default for specified scheme,
        e.g. 'http://python.org' or 'http://python.org:80', False
        otherwise.

        Return False for relative URLs.

        Nr{)r\r�r�r�r�)r�ZexplicitrBrBrC�is_default_portFs

zURL.is_default_portcCr�)z}Return an URL with scheme, host and port parts only.

        user, password, path, query and fragment are removed.

        )rMr�rBrBrC�originW�z
URL.origincCs|j|j|j|j|jfSr�)r�r�r�r�r�r�rBrBrCrK`szURL._valcCsj|j}s	td��|j}std��d|vr"|j}tdd||j�}n|js-|js-|js-|St	||ddd�S)z|Return an URL with scheme, host and port parts only.

        user, password, path, query and fragment are removed.
        �URL should be absolutezURL should have schemer}Nr{)
r�r�r�rYrr\r�r�r�r�)r�r�rP�encoded_hostrBrBrCrMds

zURL._origincCs$|jstd��tdd|j|j|j�S)zhReturn a relative part of the URL.

        scheme, user, password, host and port are removed.

        r�r{)r�r�r�r�r�r�r�rBrBrC�relativeuszURL.relativecCs
|jdkS)z�A check for absolute URLs.

        Return True for absolute ones (having scheme or starting
        with //), False otherwise.

        r{�r�r�rBrBrCrNs
zURL.absolutecCr�)zdScheme for absolute URLs.

        Empty string for relative URLs or URLs starting with //

        )r�r�rBrBrCrP�r�z
URL.schemecCr�)zQEncoded authority part of URL.

        Empty string for relative URLs.

        r�r�rBrBrCrQ�r�zURL.raw_authoritycCst|j|j|j|j�S)zQDecoded authority part of URL.

        Empty string for relative URLs.

        )rrTrVrXr[r�rBrBrCrR��z
URL.authoritycC�|��|jdS)zEEncoded user part of URL.

        None if user is missing.

        rS�r�r�r�rBrBrCrS�s
zURL.raw_usercC�|j}dur	dSt|�S)zEDecoded user part of URL.

        None if user is missing.

        N)rSr/)r�rSrBrBrCrT��zURL.usercCr�)zMEncoded password part of URL.

        None if password is missing.

        rUr�r�rBrBrCrU��
zURL.raw_passwordcCr�)zMDecoded password part of URL.

        None if password is missing.

        N)rUr/)r�rUrBrBrCrV�r�zURL.passwordcCr�)z�Encoded host part of URL.

        None for relative URLs.

        When working with IPv6 addresses, use the `host_subcomponent` property instead
        as it will return the host subcomponent with brackets.
        rWr�r�rBrBrCrW�s
zURL.raw_hostcCs6|j}dur	dS|r|d��sd|vr|St|�S)zDDecoded host part of URL.

        None for relative URLs.

        Nr�r|)rW�isdigit�_idna_decode�r��rawrBrBrCrX�s
zURL.hostcCs*|j}dur	dSd|vrd|�d�S|S)a�Return the host subcomponent part of URL.

        None for relative URLs.

        https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2

        `IP-literal = "[" ( IPv6address / IPvFuture  ) "]"`

        Examples:
        - `http://example.com:8080` -> `example.com`
        - `http://example.com:80` -> `example.com`
        - `https://127.0.0.1:8443` -> `127.0.0.1`
        - `https://[::1]:8443` -> `[::1]`
        - `http://[::1]` -> `[::1]`

        Nr|r~�])rWr�rBrBrCrY�szURL.host_subcomponentcCs�|j}dur	dS|ddkr|�d�}|j}|dus#|t�|j�kr/d|vr-d|�d�S|Sd|vr;d|�d|��S|�d|��S)aReturn the host and port subcomponent part of URL.

        Trailing dots are removed from the host part.

        This value is suitable for use in the Host header of an HTTP request.

        None for relative URLs.

        https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2
        `IP-literal = "[" ( IPv6address / IPvFuture  ) "]"`
        https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.3
        port        = *DIGIT

        Examples:
        - `http://example.com:8080` -> `example.com:8080`
        - `http://example.com:80` -> `example.com`
        - `http://example.com.:80` -> `example.com`
        - `https://127.0.0.1:8443` -> `127.0.0.1:8443`
        - `https://[::1]:8443` -> `[::1]:8443`
        - `http://[::1]` -> `[::1]`

        Nr�r�r|r~r�z]:)rW�rstripr\r�r�r�)r�r�r[rBrBrCrZs
&zURL.host_port_subcomponentcCs|j}dur	|St�|j�S)z�Port part of URL, with scheme-based fallback.

        None for relative URLs or URLs without explicit port and
        scheme without default port substitution.

        N)r\r�r�r�)r�r\rBrBrCr[+szURL.portcCr�)zyPort part of URL, without scheme-based fallback.

        None for relative URLs or URLs without explicit port.

        r\r�r�rBrBrCr\7r�zURL.explicit_portcCs|js|js	|jSdS)zNEncoded path of URL.

        / for absolute URLs without path part.

        r�)r�r�r�rBrBrCr]Ar�zURL.raw_pathcC�|jrt|j�S|jr
dSdS)zNDecoded path of URL.

        / for absolute URLs without path part.

        r�r{)r�r)r�r�rBrBrCr^JszURL.pathcCr�)z{Decoded path of URL.

        / for absolute URLs without path part.

        / (%2F) and % (%25) are not decoded

        r�r{)r�r(r�r�rBrBrC�	path_safeSs	
z
URL.path_safecC�
t|j�S)zParse query part of URL.)rr�r�rBrBrCr_`�
zURL._parsed_queryr`cCstt|j��S)z�A MultiDictProxy representing parsed query parameters in decoded
        representation.

        Empty value if URL has no query part.

        )rrr_r�rBrBrCraesz	URL.querycCr�)zOEncoded query part of URL.

        Empty string if query is missing.

        )r�r�rBrBrCrbor�zURL.raw_query_stringcC�|jrt|j�SdS)zODecoded query part of URL.

        Empty string if query is missing.

        r{)r�r*r�rBrBrCrcx�zURL.query_stringcCs |j}s|jS|j�d|��S)zDecoded path of URL with query.�?)rcr^�r��qrBrBrCrd�s zURL.path_qscCsF|j}r|js|js|j�d|��Sd|��S|js|js!|jSdS)zEncoded path of URL with query.r�z/?r�)r�r�r�r�rBrBrCre�s
&zURL.raw_path_qscCr�)zUEncoded fragment part of URL.

        Empty string if fragment is missing.

        )r�r�rBrBrCrf�r�zURL.raw_fragmentcCr�)zUDecoded fragment part of URL.

        Empty string if fragment is missing.

        r{)r�r/r�rBrBrCrg�r�zURL.fragment.cCsf|j}|jr|rdg|dd��d��RSdS|r,|ddkr,dg|dd��d��RSt|�d��S)zjA tuple containing encoded *path* parts.

        ('/',) for absolute URLs if *path* is missing.

        r�rN)r�r)r�r��splitru)r�r^rBrBrCrh�s"z
URL.raw_partscC�tdd�|jD��S)zjA tuple containing decoded *path* parts.

        ('/',) for absolute URLs if *path* is missing.

        cs��|]}t|�VqdSr��r/)�.0�partrBrBrC�	<genexpr>���zURL.parts.<locals>.<genexpr>)rurhr�rBrBrCri�r�z	URL.partscCsb|j}|r	|dkr|js|jrt|j|j|dd�S|S|�d�}t|j|jd�|dd��dd�S)z]A new URL with last part of path removed and cleaned up query and
        fragment.

        r�r{Nr�)r�r�r�r�r�r�r��join)r�r^rirBrBrCrj�s
"z
URL.parentcCs0|j}|js
|dS|dd�}|r|dSdS)zThe last part of raw_parts.r�rNr{)rhr�)r�rirBrBrCrk�s
zURL.raw_namecCr�)zThe last part of parts.)r/rkr�rBrBrCrl�r�zURL.namecCs@|j}|�d�}d|krt|�dkrnn||d�SdS)Nr�rrr{)rk�rfind�len)r�rl�irBrBrCrm�s
0zURL.raw_suffixcCr�r�)r/rmr�rBrBrCrn�s
z
URL.suffixcCs>|j}|�d�r
dS|�d�}tdd�|�d�dd�D��S)Nr�rBcss�|]}d|VqdS)r�NrB�r�rnrBrBrCr��r�z#URL.raw_suffixes.<locals>.<genexpr>r)rk�endswith�lstriprur�r�rBrBrCro�s


 zURL.raw_suffixescCr�)Ncsr�r�r�r�rBrBrCr��r�zURL.suffixes.<locals>.<genexpr>)ruror�rBrBrCrp�szURL.suffixes�pathsz
Sequence[str]cCsbg}d}tt|��D]A\}}|dk}|r"|ddkr"td|�d���|r&|nt|�}|d|vO}|�d�}|��||sH|ddkrH|dd	�n|7}q
|j}rn|�d�}	rn|	d
dkrd|	d	d
�n|	}
|
��||
7}|j}r�|r�|d
dkr�|�d�|��|r�|s�t	|j
|d�|�dd�Sd�t|��}|r�|ddkr�d|��}t	|j
||dd�S)z�
        add paths to self._path, accounting for absolute vs relative paths,
        keep existing, but do not create new, empty segments
        Frr�zAppending path z! starting from slash is forbiddenr�r{rNr�)
�	enumerate�reversedr�r&r��reverser�r��appendr�r�r�r)r�r�r��parsedZneeds_normalize�idxr^�last�segmentsZold_segments�oldr�rBrBrCr��s4
�
&

zURL._make_childcCsVt|t�s	td��|��}|j}|s |tvr d|�d�}t|��t|||j|j	|j
�S)z&Return a new URL with scheme replaced.zInvalid scheme typez<scheme replacement is not allowed for relative URLs for the r)r�rsr��lowerr�r�r�r�r�r�r�)r�rPZlower_schemer�r�rBrBrC�with_schemes
��zURL.with_schemecCst|durd}nt|t�rt|�}|j}ntd��|j}s!td��|jp%d}t||||j	�}t
|j||j|j
|j�S)z�Return a new URL with user replaced.

        Autoencode user if needed.

        Clear user/password if user is None.

        NzInvalid user typez1user replacement is not allowed for relative URLsr{)r�rsr-rUr�r�r�rYrr\r�r�r�r�r�)r�rTrVr�r�rBrBrC�	with_user&s	


z
URL.with_usercCsp|durnt|t�rt|�}ntd��|j}std��|jp d}|j}t|j	|||�}t
|j||j|j
|j�S)z�Return a new URL with password replaced.

        Autoencode password if needed.

        Clear password if argument is None.

        NzInvalid password typez5password replacement is not allowed for relative URLsr{)r�rsr-r�r�r�rYr\rrSr�r�r�r�r�)r�rVr�r�r[rBrBrC�
with_password<s	



zURL.with_passwordcCstt|t�s	td��|j}std��|std��|r t|dd�nd}|j}t|j|j	||�}t
|j||j|j
|j�S)z�Return a new URL with host replaced.

        Autoencode host if needed.

        Changing host for relative URLs is not allowed, use .join()
        instead.

        zInvalid host typez1host replacement is not allowed for relative URLszhost removing is not allowedTr�r{)r�rsr�r�r�r�r\rrSrUr�r�r�r�r�)r�rXr�r�r[rBrBrC�	with_hostRs


z
URL.with_hostcCs�|dur)t|t�st|t�stdt|�����d|kr!dks)ntd|����|j}s2td��|jp6d}t|j	|j
||�}t|j||j
|j|j�S)z`Return a new URL with port replaced.

        Clear port to default if None is passed.

        Nz port should be int or None, got ri��z&port must be between 0 and 65535, got z1port replacement is not allowed for relative URLsr{)r�rqrrr�r�r�r�rYrrSrUr�r�r�r�r�)r�r[r�r�rBrBrC�	with_portgs

z
URL.with_port)r��
keep_query�
keep_fragmentrr	cCsr|j}|st|�}|rd|vrt|�n|}|r"|ddkr"d|��}|r'|jnd}|r.|jnd}t|j||||�S)z$Return a new URL with path replaced.r�rr�r{)r�r&rr�r�r�r�)r�r^r�rr	r�rargrBrBrC�	with_pathys	
z
URL.with_pathcC�dSr�rBr�rBrBrC�
with_query��zURL.with_query�kwargscKrr�rB�r�rrBrBrCr�r
�argscOs*t|i|��pd}t|j|j|j||j�S)a[Return a new URL with query part replaced.

        Accepts any Mapping (e.g. dict, multidict.MultiDict instances)
        or str, autoencode the argument if needed.

        A sequence of (key, value) pairs is supported as well.

        It also can take an arbitrary number of keyword arguments.

        Clear query if None is passed.

        r{)r!r�r�r�r�r�)r�rrrarBrBrCr�s�cCrr�rBr�rBrBrC�extend_query�r
zURL.extend_querycKrr�rBrrBrBrCr�r
cOs\t|i|��}s|S|j}r ||ddkr|nd|��7}n|}t|j|j|j||j�S)a&Return a new URL with query part combined with the existing.

        This method will not remove existing query parameters.

        Example:
        >>> url = URL('http://example.com/?a=1&b=2')
        >>> url.extend_query(a=3, c=4)
        URL('http://example.com/?a=1&b=2&a=3&c=4')
        r��&)r!r�r�r�r�r�r�)r�rrZ	new_queryrarBrBrCr�s

 �cCrr�rBr�rBrBrCr��r
zURL.update_querycKrr�rBrrBrBrCr��r
c	Os|r
|r
d}t|��|}nt|�dkr|d}ntd��|dur#d}n\|s)|j}nVt|t�r?t|j�}|�|�t|�	��}n@t|t
�rWt|j�}|�t|��t|�	��}n(t|t
ttf�red}t|��t|t�r{t|j�}|�|�t|�	��}ntd��t|j|j|j||j�S)aReturn a new URL with query part updated.

        This method will overwrite existing query parameters.

        Example:
        >>> url = URL('http://example.com/?a=1&b=2')
        >>> url.update_query(a=3, c=4)
        URL('http://example.com/?a=3&b=2&c=4')
        z7Either kwargs or single query parameter must be presentrrNr{zAInvalid query type: bytes, bytearray and memoryview are forbiddenzRInvalid query type: only str, mapping or sequence of (key, value) pairs is allowed)r�r�r�r�rrr_�updater#�itemsrsrr"�bytes�	bytearray�
memoryviewr�rr�r�r�r�r�)	r�rrr�Zin_queryraZqmZqstr�qsrBrBrCr��sB








���query_paramscs<t|�|j��@��s
|S|�t�fdd�|j��D���S)z4Remove some keys from query part and return new URL.c3s$�|]
\}}|�vr||fVqdSr�rB)r�rl�value�Zparams_to_removerBrCr�s���z+URL.without_query_params.<locals>.<genexpr>)�setra�keysrrur)r�rrBrrC�without_query_params�s��zURL.without_query_paramscCsN|durd}n
t|t�std��t|�}|j|kr|St|j|j|j|j	|�S)z�Return a new URL with fragment replaced.

        Autoencode fragment if needed.

        Clear fragment to default if None is passed.

        Nr{zInvalid fragment type)
r�rsr�r$r�r�r�r�r�r�)r�rgrfrBrBrC�
with_fragment
s	

�zURL.with_fragment)rr	cCs�t|t�s	td��d|vrtd��t|�}|dvrtd��t|j�}|j}r<t|�dkr3|�	|�n||d<d|d	<n||d<|d	dkrJd|d	<|rO|j
nd}|rV|jnd}t|j
|d�|�||�S)
z�Return a new URL with name (last part of path) replaced.

        Query and fragment parts are cleaned up.

        Name is encoded if needed.

        zInvalid name typer�zSlash in name is not allowed�r�z..�. and .. values are forbiddenrr�r{r)r�rsr�r�r&rtrhr�r�r�r�r�r�r�r�)r�rlrr	rir�rargrBrBrC�	with_names&



z
URL.with_namernc
Cs&t|t�s	td��|r|ddkr|dksd|vr td|����|j}|s,t|�d���|j}t|�}|s9||n
|dt|��|}|dvrLtd	��t|j	�}|j
}rkt|�d
krb|�|�n||d<d|d<n||d<|ddkryd|d<|r~|jnd}|r�|j
nd}	t|j|d�|�||	�S)
z�Return a new URL with suffix (file extension of name) replaced.

        Query and fragment parts are cleaned up.

        suffix is encoded if needed.
        zInvalid suffix typerr�r�zInvalid suffix z has an empty nameNr r!rr�r{)r�rsr�r�rkrmr&r�rtrhr�r�r�r�r�r�r�)
r�rnrr	rl�
old_suffixrir�rargrBrBrC�with_suffixEs0

 "


zURL.with_suffix�urlcCs4t|�tur
td��|jp|j}||jks|tvr|S|j}r/|tvr/t|||j|j	|j
�S|j}|j}r||ddkr@|}n1|sHd|��}n)|ddkrU|�|��}nd�g|jdd��d��|}|ddkrq|dd�}d|vryt
|�n|}n|}t||j||s�|j	r�|j	n|j	|s�|j
r�|j
�S|j
�S)	u_Join URLs

        Construct a full (“absolute”) URL by combining a “base URL”
        (self) with another URL (url).

        Informally, this uses components of the base URL, in
        particular the addressing scheme, the network location and
        (part of) the path, to provide missing components in the
        relative URL.

        zurl should be URLrr�r�Nr{rr�)r�rLr�r��
USES_RELATIVEr�rr�r�r�r�r�rir)r�r%rPZjoin_netloc�	orig_pathZ	join_pathr^rBrBrCr�ns:
 ��zURL.join�r�cGs|j||d�S)zAReturn a new URL with the elements in other appended to the path.r()r�)r�r�r�rBrBrC�joinpath�szURL.joinpathcCs�t|jd�}t|jd�}|j}rd|vrd|�d�}t|jd�}tr)|dus)J�d�dd	�|j��D��}t|j	d
�}trD|dusDJ�t
||||j�}t|j
||||�S)z<Return decoded human readable string for URL representation.z#/:?@[]r|r~r�z#?Nrcss,�|]\}}d�t|d�t|d��VqdS)z{}={}z#&+;=N)�formatr0)r��k�vrBrBrCr��s
��
�z!URL.human_repr.<locals>.<genexpr>r{)r0rTrVrXr^rr�rarrgrr\rr�)r�rTrVrXr^rcrgr�rBrBrC�
human_repr�s
�zURL.human_repr�rxN)rxrL)rxr`)F)r%rLrxrL)dr=r>r?�	__slots__rJrIrsr�r
rr<rqr��classmethodrrrr�r
r�r�r�rr�r�r�r�r�r�r�r�r�r�r�rur�rr�r�r�r�r��cached_propertyrKrMr�rNrPrQrRrSrTrUrVrWrXrYrZr[r\r]r^r�rtr_rarbrcrdrerfrgrhrirjrkrlrmrnrorpr�rrrrrr
rrrr	rr�rrr"r$r�r)r-rBrBrBrCrLs�
G����
�
����
�
��
�	�

���
��^�
�

	




	


%		

/�����
�5
����
�*����
�
)4�ir�cCs6z	t�|�d��WSty|�d��d�YSw)Nr��idna)r3�decoder��UnicodeError)r�rBrBrCr��s
�r�cCs:ztj|dd��d�WSty|�d��d�YSw)NT)Zuts46r�r3)r3r�r4r5)rXrBrBrC�_idna_encode�s
�r6r�c
	Cs|rH|d��sd|vrH|�d�\}}}zt|�}Wn	ty#Yn%w|j}|jdkr=|r7d|�d|�d�Sd|�d�S|rF|�d|��S|S|��r�|��}|r�t�	|�}r�|�
�|��d}}}	|dksu|dkrwd||d	�vrwd
}	td|�d|�d
|�d|	���d	�|St|�S)zEncode host part of URL.r�r|�%�r~r�r{r}NzQ, if the value includes a username or password, use 'authority' instead of 'host'zHost z cannot contain z (at position �))
r��	partitionrr��
compressed�version�isasciir�NOT_REG_NAME�search�group�startr6)
rXr�Zraw_ip�sep�zone�ip�invalidr�pos�extrarBrBrCr��s2�
" ���r�cCst��t��t��dS)zClear all LRU caches.N)r6�cache_clearr�r�rBrBrBrCrHsrHcCs$t��t��t��t��t��d�S)zReport cache statistics.)rErFrrGrH)r6�
cache_infor�r�rBrBrBrCrIs�rI)�idna_encode_size�idna_decode_size�ip_address_size�host_validate_size�encode_host_sizerJrKrLrMrNcCs�|tus|turtjdtdd�|durL||fD]-}|dur!d}q|tur,|tur+|}q|turEtr@t|t�s9J�t|t�s@J�t||�}q|turLt}t	|�t
j�a
t	|�tj�at	|�t
j�a
dS)zConfigure LRU cache sizes.z�cache_configure() no longer accepts the ip_address_size or host_validate_size arguments, they are used to set the encode_host_size instead and will be removed in the future�)�
stacklevelN)r�r�r��DeprecationWarningrr�rr�max�_DEFAULT_ENCODE_SIZErr��__wrapped__r�r6)rJrKrLrMrN�sizerBrBrC�cache_configures2
�	�
�rVr.)`�re�sysr��collections.abcrr�enumr�	functoolsrr�	ipaddressr�typingrr	r
rrr
r�urllib.parserrr3Z	multidictrrZ
propcache.apirr1�_parserrrrrrrr�rrr�rrr r!r"r#Z_quotersr$r%r&r'r(r)r*r+r,r-r.r/r0r��	frozensetr&r��compile�VERBOSEr>r8�version_infor;r<rAr�rDrJryrsr�r�rrr�r�r�rLZ_DEFAULT_IDNA_SIZErSr�r6rqr�rHrIrVrBrBrBrC�<module>s�$$	 <	�

'?	��
�
��
���	�
� �����
�69�
�
�����