o
    JAf&                     @   s  	 d dl Z d dlZd dlZd dlZd dlZg dZg dZg dZg dZg dZ	g dZ
g dZd	Zg d
ZdZi Zdd ZdZdZdd ZeefddZeefddZdd ZG dd deZG dd deZG dd deZG dd deeZG d d! d!eeZd d"lmZ ed#d$Zed%d&Zed'd(Z d)e_!d*ej"_!d+ej#_!d,e_!d-ej$_!d.ej%_!d/ej&_!d0ej'_!d1ej#_!d2e _!ej$j!e j$_!ej%j!e j%_!ej&j!e j&_!d3e j(_!ej'j!e j'_!ej#j!e j#_!eZ)G d4d# d#eeZ*G d5d% d%eeZ+G d6d' d'e eZ,G d7d8 d8eeZ-G d9d: d:eeZ.G d;d< d<e eZ/d=d> Z0e0  [0ddAdBZ1dCdD Z2ddEdFZ3dGdH Z4ddIdJZ5dKdL Z6dMdN Z7ddOdPZ8dQdR Z9dSZ:da;dTdU Z<e =dVZ>ddYdZZ?	[	\dd]d^Z@	[	\dd_d`ZAddadbZBeCdcZDeEeDZFi ZGG ddde deejHZIddgdhZJddidjZKddkdlZLd[d?ddeKfdmdnZMdodp ZNdqdr ZOdsdt ZPdudv ZQdaRdwdx ZSdydz ZTdaUd{d| ZVd}d~ ZWdd ZXdd ZYdd ZZdd Z[da\dd Z]dddZ^dddZ_dd Z`dd Zadd Zbdd Zcdd Zddd Zedd Zfdd ZgdS )    N)urlparse
urlunparseurljoin	urldefragurlsplit
urlunsplit	urlencodeparse_qs	parse_qslquote
quote_plusquote_from_bytesunquoteunquote_plusunquote_to_bytesDefragResultParseResultSplitResultDefragResultBytesParseResultBytesSplitResultBytes) ftphttpgophernntpimapwaisfilehttpsshttpmmsprosperortsprtspusftpsvnsvn+sshwswss)r   r   r   r   r   telnetr   r   r   r!   r   r    snewsr"   r#   r$   rsyncr&   r'   r%   nfsgitzgit+sshr(   r)   )r   r   hdlr"   r   r   r   r    r#   r$   sipsipsr!   r%   tel)
r   r/   mailtonewsr*   r   r   r+   r0   r1   )r   r   r   r   r   r    r!   r   r#   r$   r0   r1   )r   r   r/   r   r   r4   r   r   r   r    r+   r   r"   zAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.)	
   c                   C   s   	 t   t  d S N)_parse_cacheclear_safe_quoters r=   r=   #/usr/lib/python3.10/urllib/parse.pyclear_cacheX   s   r?   asciistrictc                 C   s   | S r9   r=   )objr=   r=   r>   _noopg   s   rC   c                 C   s   |  ||S r9   encode)rB   encodingerrorsr=   r=   r>   _encode_resultj   s   rH   c                    s   t  fdd| D S )Nc                 3   s$    | ]}|r|  nd V  qdS )r   Ndecode.0xrF   rG   r=   r>   	<genexpr>p   s   " z_decode_args.<locals>.<genexpr>)tuple)argsrF   rG   r=   rN   r>   _decode_argsn   s   rR   c                  G   sV   t | d t}| dd  D ]}|rt |t|krtdq|r$| tf S t| tf S )Nr      z$Cannot mix str and non-str arguments)
isinstancestr	TypeErrorrC   rR   rH   )rQ   	str_inputargr=   r=   r>   _coerce_argsr   s   
rY   c                   @      e Zd Z	 dZdddZdS )_ResultMixinStrr=   r@   rA   c                       | j  fdd| D  S )Nc                 3       | ]	}|  V  qd S r9   rD   rK   rN   r=   r>   rO          z)_ResultMixinStr.encode.<locals>.<genexpr>)_encoded_counterpartselfrF   rG   r=   rN   r>   rE         z_ResultMixinStr.encodeNr@   rA   )__name__
__module____qualname__	__slots__rE   r=   r=   r=   r>   r[          r[   c                   @   rZ   )_ResultMixinBytesr=   r@   rA   c                    r\   )Nc                 3   r]   r9   rI   rK   rN   r=   r>   rO      r^   z+_ResultMixinBytes.decode.<locals>.<genexpr>)_decoded_counterpartr`   r=   rN   r>   rJ      rb   z_ResultMixinBytes.decodeNrc   )rd   re   rf   rg   rJ   r=   r=   r=   r>   ri      rh   ri   c                   @   sL   e Zd Z	 dZedd Zedd Zedd Zedd	 Ze	e
jZd
S )_NetlocResultMixinBaser=   c                 C   
   | j d S )Nr   	_userinfora   r=   r=   r>   username      
z_NetlocResultMixinBase.usernamec                 C   rl   )NrS   rm   ro   r=   r=   r>   password   rq   z_NetlocResultMixinBase.passwordc                 C   sD   | j d }|s	d S t|trdnd}||\}}}| | | S )Nr   %   %)	_hostinforT   rU   	partitionlower)ra   hostname	separatorpercentzoner=   r=   r>   rx      s   
z_NetlocResultMixinBase.hostnamec                 C   sl   | j d }|d ur4zt|d}W n ty!   d|}t|d w d|  kr/dks4td td|S )NrS   
   z+Port could not be cast to integer value as r   i  zPort out of range 0-65535)ru   int
ValueError)ra   portmessager=   r=   r>   r      s   


z_NetlocResultMixinBase.portN)rd   re   rf   rg   propertyrp   rr   rx   r   classmethodtypesGenericAlias__class_getitem__r=   r=   r=   r>   rk      s    




rk   c                   @   (   e Zd ZdZedd Zedd ZdS )_NetlocResultMixinStrr=   c                 C   J   | j }|d\}}}|r|d\}}}|sd }||fS d  }}||fS )N@:netloc
rpartitionrv   ra   r   userinfo	have_infohostinforp   have_passwordrr   r=   r=   r>   rn         z_NetlocResultMixinStr._userinfoc                 C   l   | j }|d\}}}|d\}}}|r&|d\}}}|d\}}}n|d\}}}|s2d }||fS )Nr   []r   r   ra   r   _r   have_open_br	bracketedrx   r   r=   r=   r>   ru         z_NetlocResultMixinStr._hostinfoNrd   re   rf   rg   r   rn   ru   r=   r=   r=   r>   r          
r   c                   @   r   )_NetlocResultMixinBytesr=   c                 C   r   )N   @   :r   r   r=   r=   r>   rn      r   z!_NetlocResultMixinBytes._userinfoc                 C   r   )Nr      [   ]r   r   r   r=   r=   r>   ru      r   z!_NetlocResultMixinBytes._hostinfoNr   r=   r=   r=   r>   r      r   r   )
namedtupler   zurl fragmentr   z!scheme netloc path query fragmentr   z(scheme netloc path params query fragmentz
DefragResult(url, fragment)

A 2-tuple that contains the url without fragment identifier and the fragment
identifier as a separate argument.
z$The URL with no fragment identifier.z
Fragment identifier separated from URL, that allows indirect identification of a
secondary resource by reference to a primary resource and additional identifying
information.
z
SplitResult(scheme, netloc, path, query, fragment)

A 5-tuple that contains the different components of a URL. Similar to
ParseResult, but does not split params.
z%Specifies URL scheme for the request.z0
Network location where the request is made to.
z@
The hierarchical path, such as the path to a file to download.
z
The query component, that contains non-hierarchical data, that along with data
in path component, identifies a resource in the scope of URI's scheme and
network location.
z
Fragment identifier, that allows indirect identification of a secondary resource
by reference to a primary resource and additional identifying information.
zq
ParseResult(scheme, netloc, path, params, query, fragment)

A 6-tuple that contains components of a parsed URL.
z
Parameters for last path element used to dereference the URI in order to provide
access to perform some operation on the resource.
c                   @      e Zd ZdZdd ZdS )r   r=   c                 C      | j r| jd | j  S | jS N#fragmenturlro   r=   r=   r>   geturlC     zDefragResult.geturlNrd   re   rf   rg   r   r=   r=   r=   r>   r   A      c                   @   r   )r   r=   c                 C      t | S r9   r   ro   r=   r=   r>   r   K     zSplitResult.geturlNr   r=   r=   r=   r>   r   I  r   c                   @   r   )r   r=   c                 C   r   r9   r   ro   r=   r=   r>   r   P  r   zParseResult.geturlNr   r=   r=   r=   r>   r   N  r   c                   @   r   )r   r=   c                 C   r   )N   #r   ro   r=   r=   r>   r   V  r   zDefragResultBytes.geturlNr   r=   r=   r=   r>   r   T  r   r   c                   @   r   )r   r=   c                 C   r   r9   r   ro   r=   r=   r>   r   ^  r   zSplitResultBytes.geturlNr   r=   r=   r=   r>   r   \  r   r   c                   @   r   )r   r=   c                 C   r   r9   r   ro   r=   r=   r>   r   c  r   zParseResultBytes.geturlNr   r=   r=   r=   r>   r   a  r   r   c                  C   s4   t tfttfttff} | D ]
\}}||_||_qd S r9   )r   r   r   r   r   r   r_   rj   )Z_result_pairsZ_decodedZ_encodedr=   r=   r>   _fix_result_transcodingg  s   r   r   Tc           
      C   sh   	 t | |\} }}t| ||}|\}}} }}|tv r%d| v r%t| \} }nd}t||| |||}	||	S )N;r   )rY   r   uses_params_splitparamsr   )
r   schemeallow_fragments_coerce_resultsplitresultr   queryr   paramsresultr=   r=   r>   r   t  s   r   c                 C   sR   d| v r|  d| d}|dk r| dfS n|  d}| d | | |d d  fS )N/r   r   r   rS   )findrfind)r   ir=   r=   r>   r     s   
r   c                 C   sH   t | }dD ]}| ||}|dkrt||}q| || | |d  fS )Nz/?#r   )lenr   min)r   startdelimcwdelimr=   r=   r>   _splitnetloc  s   
r   c                 C   s   | r|   rd S dd l}| dd}|dd}|dd}|dd}|d|}||kr0d S dD ]}||v rBtd	|  d
 d q2d S )Nr   r   r   r   r   ?NFKCz/?#@:znetloc 'z' contains invalid z#characters under NFKC normalization)isasciiunicodedatareplace	normalizer~   )r   r   nnetloc2r   r=   r=   r>   _checknetloc  s"   r   c                 C   s|  	 t | |\} }}tD ]}| |d} ||d}qt|}| ||t| t|f}t|d }|r5||S tttkr>t	  d } }}	| 
d}
|
dkrm| d |
 D ]}|tvr[ nqS| d |
  | |
d d  }} | d d dkrt| d\}} d|v rd|vsd|v rd|vrtd	|rd
| v r| d
d\} }	d| v r| dd\} }t| t||| ||	}|t|< ||S )Nr   r   r   rS      //r   r   zInvalid IPv6 URLr   r   )rY   _UNSAFE_URL_BYTES_TO_REMOVEr   booltyper:   getr   MAX_CACHE_SIZEr?   r   scheme_charsrw   r   r~   splitr   r   )r   r   r   r   bkeycachedr   r   r   r   r   vr=   r=   r>   r     sB   
"r   c                 C   s>   	 t |  \}}}}}}}|rd||f }|t|||||fS )Nz%s;%s)rY   r   )
componentsr   r   r   r   r   r   r   r=   r=   r>   r     s   r   c                 C   s   	 t |  \}}}}}}|s|r1|tv r1|d d dkr1|r)|d d dkr)d| }d|p-d | }|r9|d | }|rA|d | }|rI|d | }||S )	Nr   r   rS   r   r   r   r   r   )rY   uses_netloc)r   r   r   r   r   r   r   r=   r=   r>   r     s    r   c              	   C   s  	 | s|S |s	| S t | |\} }}t| d|\}}}}}}	t|||\}
}}}}}|
|ks1|
tvr5||S |
tv rI|rG|t|
|||||fS |}|sa|sa|}|}|sU|}|t|
|||||fS |d}|d dkro|d= |d d dkr}|d}n||d }td |dd |dd< g }|D ] }|dkrz|  W q ty   Y qw |dkrq|	| q|d dv r|	d |t|
|d
|pd|||fS )Nr   r   rS   ...)r   r   )rY   r   uses_relativer   r   r   filterpop
IndexErrorappendjoin)baser   r   r   bschemebnetlocbpathbparamsbquery	bfragmentr   r   pathr   r   r   
base_partssegmentsresolved_pathsegr=   r=   r>   r     sf   





r   c           	      C   sV   	 t | \} }d| v r t| \}}}}}}t|||||df}nd}| }|t||S )Nr   r   )rY   r   r   r   )	r   r   sr   paqfragdefragr=   r=   r>   r   Q  s   r   0123456789ABCDEFabcdefc              	   C   s   	 | s| j  dS t| tr| d} |  d}t|dkr| S |d g}|j}td u r2dd tD a|dd  D ]'}z|t|d d   ||dd   W q8 ty_   |d || Y q8w d	|S )	N    utf-8rt   rS   r   c                 S   s.   i | ]}t D ]}||  t|| qqS r=   )_hexdigrE   bytesfromhex)rL   r   r   r=   r=   r>   
<dictcomp>w  s
    z$unquote_to_bytes.<locals>.<dictcomp>r   )
r   rT   rU   rE   r   r   
_hextobyter   KeyErrorr   )stringbitsresr   itemr=   r=   r>   r   d  s0   




r   z([ -]+)r   r   c                 C   s   	 t | trt| ||S d| vr| j | S |d u rd}|d u r#d}t| }|d g}|j}tdt|dD ]}|t|| || |||d   q8d	|S )Nrs   r   r   r   rS   r   r   )
rT   r  r   rJ   r   _asciirer   ranger   r   )r  rF   rG   r  r  r   r   r=   r=   r>   r     s"   
	


r   F&c              	   C   sP   	 i }t | ||||||d}|D ]\}	}
|	|v r ||	 |
 q|
g||	< q|S )N)rF   rG   max_num_fieldsry   )r
   r   )qskeep_blank_valuesstrict_parsingrF   rG   r  ry   parsed_resultpairsnamevaluer=   r=   r>   r	     s   r	   c                 C   s"  	 t | \} }t |\}}|rt|ttfstd|d ur-d| | }	||	k r-tdg }
| |D ]Z}|s;|s;q4|dd}t|dkrY|rPtd|f |rX|d nq4t|d sa|r|d 	d	d
}t
|||d}||}|d 	d	d
}t
|||d}||}|
||f q4|
S )Nz*Separator must be of type string or bytes.rS   zMax number of fields exceeded=r   zbad query field: %rr   r   + rN   )rY   rT   rU   r  r~   countr   r   r   r   r   )r  r  r  rF   rG   r  ry   r   r   
num_fieldsr
name_valuenvr  r  r=   r=   r>   r
     s<   r
   c                 C   s   	 |  dd} t| ||S )Nr  r  )r   r   )r  rF   rG   r=   r=   r>   r     s   r   sB   ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-~c                   @   s&   e Zd Z	 dd Zdd Zdd ZdS )Quoterc                 C   s   	 t || _d S r9   )_ALWAYS_SAFEunionsafe)ra   r   r=   r=   r>   __init__$  s   zQuoter.__init__c                 C   s   d| j jt| f S )Nz<%s %r>)	__class__rd   dictro   r=   r=   r>   __repr__(  s   zQuoter.__repr__c                 C   s(   || j v r	t|nd|}|| |< |S )Nz%{:02X})r   chrformat)ra   r   r  r=   r=   r>   __missing__,  s   zQuoter.__missing__N)rd   re   rf   r!  r$  r'  r=   r=   r=   r>   r    s
    r  r   c                 C   sd   	 t | tr| s
| S |d u rd}|d u rd}| ||} n|d ur%td|d ur-tdt| |S )Nr   rA   z,quote() doesn't support 'encoding' for bytesz*quote() doesn't support 'errors' for bytes)rT   rU   rE   rV   r   )r  r   rF   rG   r=   r=   r>   r   2  s   
&
r   c                 C   sf   	 t | tr
d| vst | trd| vrt| |||S t |tr"d}nd}t| || ||} | ddS )Nr      r  )rT   rU   r  r   r   )r  r   rF   rG   spacer=   r=   r>   r   h  s   
r   c                    s   	 t | ttfstd| sdS t |tr|dd}n	tdd |D }| t| s0|  S zt	|  W n t
yH   t|j t	|<  Y nw d fdd| D S )Nz!quote_from_bytes() expected bytesr   r@   ignorec                 S   s   g | ]}|d k r|qS )   r=   )rL   r   r=   r=   r>   
<listcomp>  s    z$quote_from_bytes.<locals>.<listcomp>c                    s   g | ]} |qS r=   r=   )rL   charquoterr=   r>   r,    s    )rT   r  	bytearrayrV   rU   rE   rstrip_ALWAYS_SAFE_BYTESrJ   r<   r  r  __getitem__r   )bsr   r=   r.  r>   r   y  s    
r   c              	   C   s  	 t | dr|  } n%zt| rt| d tstW n ty/   t \}}}td|w g }	|sm| D ]5\}
}t|
t	rE||
|}
n	|t
|
|||}
t|t	rY|||}n	|t
||||}|	|
d |  q6n| D ]\}
}t|
t	r~||
|}
n	|t
|
|||}
t|t	r|||}|	|
d |  qot|t
r|||||}|	|
d |  qozt|}W n ty   |t
||||}|	|
d |  Y qow |D ]}t|t	r|||}n	|t
||||}|	|
d |  qqod|	S )Nitemsr   z1not a valid non-string sequence or mapping objectr  r  )hasattrr5  r   rT   rP   rV   sysexc_infowith_tracebackr  rU   r   r   )r   doseqr   rF   rG   	quote_viatyvatblkr   rM   eltr=   r=   r>   r     s^   









r   c                 C      t jdtdd t| S )Nz/urllib.parse.to_bytes() is deprecated as of 3.8r   
stacklevel)warningswarnDeprecationWarning	_to_bytesr   r=   r=   r>   to_bytes  s   rJ  c                 C   sH   	 t | tr"z
| d } W | S  ty!   tdt|  d w | S )NASCIIzURL z contains non-ASCII characters)rT   rU   rE   rJ   UnicodeErrorreprrI  r=   r=   r>   rH    s   
rH  c                 C   sb   	 t |  } | d d dkr| dd  dkr| dd  } | d d dkr/| dd   } | S )NrS   <r   >   zURL:)rU   striprI  r=   r=   r>   unwrap  s    rR  c                 C   rB  )NzUurllib.parse.splittype() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr   rC  )rE  rF  rG  
_splittyperI  r=   r=   r>   	splittype     rT  c                 C   sF   	 t d u rtdtja t | }|r| \}}| |fS d | fS )Nz([^/:]+):(.*))	_typeprogrecompileDOTALLmatchgroupsrw   )r   rZ  r   datar=   r=   r>   rS  	  s   
rS  c                 C   rB  )NzUurllib.parse.splithost() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr   rC  )rE  rF  rG  
_splithostrI  r=   r=   r>   	splithost  rU  r^  c                 C   sZ   	 t d u rtdtja t | }|r)| \}}|r%|d dkr%d| }||fS d | fS )Nz//([^/#?]*)(.*)r   r   )	_hostprogrW  rX  rY  rZ  r[  )r   rZ  	host_portr   r=   r=   r>   r]    s   
r]  c                 C   rB  )NzUurllib.parse.splituser() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr   rC  )rE  rF  rG  
_splituserhostr=   r=   r>   	splituser-  rU  rd  c                 C   s&   	 |  d\}}} |r|| fS d | fS )Nr   r   )rc  userr   r=   r=   r>   ra  4  s   ra  c                 C   rB  )NzWurllib.parse.splitpasswd() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr   rC  )rE  rF  rG  _splitpasswd)rf  r=   r=   r>   splitpasswd:  rU  rh  c                 C   $   	 |  d\} }}| |r|fS d fS Nr   rv   )rf  r   passwdr=   r=   r>   rg  A     rg  c                 C   rB  )NzUurllib.parse.splitport() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr   rC  )rE  rF  rG  
_splitportrb  r=   r=   r>   	splitportG  rU  ro  c                 C   sF   	 t d u rtdtja t | }|r| \} }|r| |fS | d fS )Nz(.*):([0-9]*))	_portprogrW  rX  rY  	fullmatchr[  )rc  rZ  r   r=   r=   r>   rn  P  s   
rn  r   c                 C   s   t jdtdd t| |S )NzVurllib.parse.splitnport() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr   rC  )rE  rF  rG  _splitnport)rc  defportr=   r=   r>   
splitnport^  s   
rt  c                 C   s^   	 |  d\} }}|s|} | |fS |r+z	t|}W | |fS  ty*   d }Y | |fS w | |fS rj  )r   r}   r~   )rc  rs  r   r   nportr=   r=   r>   rr  e  s   
rr  c                 C   rB  )NzVurllib.parse.splitquery() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr   rC  )rE  rF  rG  _splitqueryrI  r=   r=   r>   
splitqueryv  rU  rw  c                 C   &   	 |  d\}}}|r||fS | d fS )Nr   re  )r   r   r   r   r=   r=   r>   rv  }  
   rv  c                 C   rB  )NzTurllib.parse.splittag() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr   rC  )rE  rF  rG  	_splittagrI  r=   r=   r>   splittag  rU  r{  c                 C   rx  r   re  )r   r   r   tagr=   r=   r>   rz    ry  rz  c                 C   rB  )NzUurllib.parse.splitattr() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr   rC  )rE  rF  rG  
_splitattrrI  r=   r=   r>   	splitattr  rU  r~  c                 C   s    	 |  d}|d |dd  fS )Nr   r   rS   )r   )r   wordsr=   r=   r>   r}    s   
r}  c                 C   rB  )NzWurllib.parse.splitvalue() is deprecated as of 3.8, use urllib.parse.parse_qsl() insteadr   rC  )rE  rF  rG  _splitvalue)attrr=   r=   r>   
splitvalue  rU  r  c                 C   ri  )Nr  rk  )r  r   r  r=   r=   r>   r    rm  r  )r   T)r   )T)r   r   )FFr   r   Nr  )r   NN)r   NN)r   )r   )hrW  r7  r   collectionsrE  __all__r   r   r   non_hierarchical
uses_queryuses_fragmentr   r   r   r:   r?   _implicit_encoding_implicit_errorsrC   rH   rR   rY   objectr[   ri   rk   r   r   r   _DefragResultBase_SplitResultBase_ParseResultBase__doc__r   r   r   r   r   r   r   
ResultBaser   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   rX  r
  r   r	   r
   r   	frozensetr  r  r2  r<   defaultdictr  r   r   r   r   rJ  rH  rR  rT  rV  rS  r^  r_  r]  rd  ra  rh  rg  ro  rp  rn  rt  rr  rw  rv  r{  rz  r~  r}  r  r  r=   r=   r=   r>   <module>   s    

'



	
9
E


*

B	

6

Q

