/ lib / urllib / parse.pyc
parse.pyc
  1  o

  2  ���cǩ�@s�dZddlZddlZddlZddlZddlZgd�Zgd�Zgd�Zgd�Z	gd�Z
  3  gd�Zgd	�Zd
  4  Z
gd�ZdZiZd
d�ZdZdZdd�Zeefdd�Zeefdd�Zdd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d ee�ZGd!d"�d"ee�Zdd#lmZed$d%�Zed&d'�Z ed(d)�Z!d*e_d+ej"_d,ej#_d-e _d.e j$_d/e j%_d0e j&_d1e j'_d2e j#_d3e!_e j$je!j$_e j%je!j%_e j&je!j&_d4e!j(_e j'je!j'_e j#je!j#_eZ)Gd5d$�d$ee�Z*Gd6d&�d&e e�Z+Gd7d(�d(e!e�Z,Gd8d9�d9ee�Z-Gd:d;�d;e e�Z.Gd<d=�d=e!e�Z/d>d?�Z0e0�[0d�dBdC�Z1dDdE�Z2d�dFdG�Z3dHdI�Z4d�dJdK�Z5dLdM�Z6dNdO�Z7d�dPdQ�Z8dRdS�Z9dTZ:da;dUdV�Z<e�=dW�Z>d�dZd[�Z?	\	]d�d^d_�Z@	\	]d�d`da�ZAd�dbdc�ZBeCdd�ZDeEeD�ZFiZGGdedf�dfejH�ZId�dhdi�ZJd�djdk�ZKd�dldm�ZLd\d@ddeKfdndo�ZMdpdq�ZNdrds�ZOdtdu�ZPdvdw�ZQdaRdxdy�ZSdzd{�ZTdaUd|d}�ZVd~d�ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[da\d�d��Z]d�d�d��Z^d�d�d��Z_d�d��Z`d�d��Zad�d��Zbd�d��Zcd�d��Zdd�d��Zed�d��Zfd�d��ZgdS)�acParse (absolute and relative) URLs.
  5  
  6  urlparse module is based upon the following RFC specifications.
  7  
  8  RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding
  9  and L.  Masinter, January 2005.
 10  
 11  RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter
 12  and L.Masinter, December 1999.
 13  
 14  RFC 2396:  "Uniform Resource Identifiers (URI)": Generic Syntax by T.
 15  Berners-Lee, R. Fielding, and L. Masinter, August 1998.
 16  
 17  RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zawinski, July 1998.
 18  
 19  RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June
 20  1995.
 21  
 22  RFC 1738: "Uniform Resource Locators (URL)" by T. Berners-Lee, L. Masinter, M.
 23  McCahill, December 1994
 24  
 25  RFC 3986 is considered the current standard and any future changes to
 26  urlparse module should conform with it.  The urlparse module is
 27  currently not entirely compliant with this RFC due to defacto
 28  scenarios for parsing, and for backward compatibility purposes, some
 29  parsing quirks from older RFCs are retained. The testcases in
 30  test_urlparse.py provides a good indicator of parsing behavior.
 31  �N)�urlparse�
 32  urlunparse�urljoin�	urldefrag�urlsplit�
 33  urlunsplit�	urlencode�parse_qs�	parse_qsl�quote�
 34  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)rrrrr�telnetrrrr!rr �snewsr"r#r$�rsyncr&r'r%�nfs�gitzgit+sshr(r))rr�hdlr"rrrr r#r$�sip�sipsr!r%�tel)
 35  rr/�mailto�newsr*rrr+r0r1)rrrrrr r!rr#r$r0r1)
rrr/rrr4rrrr r+rr"zAabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.)�	�
�
 36  �cCst��t��dS)z,Clear the parse cache and the quoters cache.N)�_parse_cache�clear�
_safe_quoters�r<r<�tC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\urllib\parse.py�clear_cacheXsr>�ascii�strictcCs|S�Nr<)�objr<r<r=�_noopgsrCcCs|�||�SrA��encode)rB�encoding�errorsr<r<r=�_encode_resultjsrHcst��fdd�|D��S)Nc3s$�|]
}|r|����ndVqdS)rN��decode��.0�x�rFrGr<r=�	<genexpr>ps�"z_decode_args.<locals>.<genexpr>)�tuple)�argsrFrGr<rNr=�_decode_argsnsrRcGsVt|dt�}|dd�D]}|rt|t�|krtd��q
|r$|tfSt|�tfS)Nr�z$Cannot mix str and non-str arguments)�
 37  isinstance�str�	TypeErrorrCrRrH)rQ�	str_input�argr<r<r=�_coerce_argsrs�
 38  rYc@�eZdZdZdZddd�ZdS)	�_ResultMixinStrz>Standard approach to encoding parsed results from str to bytesr<r?r@c�|j��fdd�|D��S)Nc3��|]	}|����VqdSrArDrKrNr<r=rO���z)_ResultMixinStr.encode.<locals>.<genexpr>)�_encoded_counterpart��selfrFrGr<rNr=rE��z_ResultMixinStr.encodeN�r?r@)�__name__�
 39  __module__�__qualname__�__doc__�	__slots__rEr<r<r<r=r[��r[c@rZ)	�_ResultMixinBytesz>Standard approach to decoding parsed results from bytes to strr<r?r@cr\)Nc3r]rArIrKrNr<r=rO�r^z+_ResultMixinBytes.decode.<locals>.<genexpr>)�_decoded_counterpartr`r<rNr=rJ�rbz_ResultMixinBytes.decodeNrc)rdrerfrgrhrJr<r<r<r=rj�rirjc@sNeZdZdZdZedd��Zedd��Zedd��Zed	d
 40  ��Z	e
 41  ej�Z
dS)�_NetlocResultMixinBasezHShared methods for the parsed result objects containing a netloc elementr<cC�
 42  |jdS)Nr��	_userinfo�rar<r<r=�username��
 43  z_NetlocResultMixinBase.usernamecCrm)NrSrnrpr<r<r=�password�rrz_NetlocResultMixinBase.passwordcCsD|jd}|s	dSt|t�rdnd}|�|�\}}}|��||S)Nr�%�%)�	_hostinforTrU�	partition�lower)ra�hostname�	separator�percent�zoner<r<r=ry�s
 44  z_NetlocResultMixinBase.hostnamecCsb|jd}|dur/|��r|��rt|�}ntd|����d|kr*dks/td��td��|S)NrSz+Port could not be cast to integer value as ri��zPort out of range 0-65535)rv�isdigit�isascii�int�
 45  ValueError)ra�portr<r<r=r��s
 46  
 47  �z_NetlocResultMixinBase.portN)rdrerfrgrh�propertyrqrsryr��classmethod�types�GenericAlias�__class_getitem__r<r<r<r=rl�s
 48  
 49  
 50  
 51  
 52  rlc@�(eZdZdZedd��Zedd��ZdS)�_NetlocResultMixinStrr<cC�J|j}|�d�\}}}|r|�d�\}}}|sd}||fSd}}||fS)N�@�:��netloc�
 53  rpartitionrw�rar��userinfo�	have_info�hostinforq�
have_passwordrsr<r<r=ro���z_NetlocResultMixinStr._userinfocC�l|j}|�d�\}}}|�d�\}}}|r&|�d�\}}}|�d�\}}}n|�d�\}}}|s2d}||fS)Nr��[�]r�r��rar��_r��have_open_br�	bracketedryr�r<r<r=rv��z_NetlocResultMixinStr._hostinfoN�rdrerfrhr�rorvr<r<r<r=r���
 54  r�c@r�)�_NetlocResultMixinBytesr<cCr�)N�@�:r�r�r<r<r=ro�r�z!_NetlocResultMixinBytes._userinfocCr�)Nr��[�]r�r�r�r<r<r=rv�r�z!_NetlocResultMixinBytes._hostinfoNr�r<r<r<r=r��r�r�)�
 55  namedtuplerzurl fragmentrz!scheme netloc path query fragmentrz(scheme netloc path params query fragmentz�
 56  DefragResult(url, fragment)
 57  
 58  A 2-tuple that contains the url without fragment identifier and the fragment
 59  identifier as a separate argument.
 60  z$The URL with no fragment identifier.z�
 61  Fragment identifier separated from URL, that allows indirect identification of a
 62  secondary resource by reference to a primary resource and additional identifying
 63  information.
 64  z�
 65  SplitResult(scheme, netloc, path, query, fragment)
 66  
 67  A 5-tuple that contains the different components of a URL. Similar to
 68  ParseResult, but does not split params.
 69  z%Specifies URL scheme for the request.z0
 70  Network location where the request is made to.
 71  z@
 72  The hierarchical path, such as the path to a file to download.
 73  z�
 74  The query component, that contains non-hierarchical data, that along with data
 75  in path component, identifies a resource in the scope of URI's scheme and
 76  network location.
 77  z�
 78  Fragment identifier, that allows indirect identification of a secondary resource
 79  by reference to a primary resource and additional identifying information.
 80  zq
 81  ParseResult(scheme, netloc, path, params, query, fragment)
 82  
 83  A 6-tuple that contains components of a parsed URL.
 84  z�
 85  Parameters for last path element used to dereference the URI in order to provide
 86  access to perform some operation on the resource.
 87  c@�eZdZdZdd�ZdS)rr<cC�|jr|jd|jS|jS)N�#��fragment�urlrpr<r<r=�geturlB�zDefragResult.geturlN�rdrerfrhr�r<r<r<r=r@�c@r�)rr<cC�t|�SrA�rrpr<r<r=r�J�zSplitResult.geturlNr�r<r<r<r=rHr�c@r�)rr<cCr�rA�rrpr<r<r=r�Or�zParseResult.geturlNr�r<r<r<r=rMr�c@r�)rr<cCr�)N�#r�rpr<r<r=r�Ur�zDefragResultBytes.geturlNr�r<r<r<r=rSr�rc@r�)rr<cCr�rAr�rpr<r<r=r�]r�zSplitResultBytes.geturlNr�r<r<r<r=r[r�rc@r�)rr<cCr�rAr�rpr<r<r=r�br�zParseResultBytes.geturlNr�r<r<r<r=r`r�rcCs4ttfttfttff}|D]
 88  \}}||_||_q
dSrA)rrrrrrr_rk)Z
_result_pairsZ_decodedZ_encodedr<r<r=�_fix_result_transcodingfs��r�rTc
 89  Csft||�\}}}t|||�}|\}}}}}|tvr$d|vr$t|�\}}nd}t||||||�}	||	�S)a�Parse a URL into 6 components:
 90      <scheme>://<netloc>/<path>;<params>?<query>#<fragment>
 91  
 92      The result is a named 6-tuple with fields corresponding to the
 93      above. It is either a ParseResult or ParseResultBytes object,
 94      depending on the type of the url parameter.
 95  
 96      The username, password, hostname, and port sub-components of netloc
 97      can also be accessed as attributes of the returned object.
 98  
 99      The scheme argument provides the default value of the scheme
100      component when no scheme is found in url.
101  
102      If allow_fragments is False, no attempt is made to separate the
103      fragment component from the previous component, which can be either
104      path or query.
105  
106      Note that % escapes are not expanded.
107      �;r)rYr�uses_params�_splitparamsr)
108  r��scheme�allow_fragments�_coerce_result�splitresultr��queryr��params�resultr<r<r=rssrcCsRd|vr|�d|�d��}|dkr|dfSn|�d�}|d|�||dd�fS)N�/r�rrrS)�find�rfind)r��ir<r<r=r��s�
109  r�cCsHt|�}dD]}|�||�}|dkrt||�}q|||�||d�fS)Nz/?#r)�lenr��min)r��start�delim�c�wdelimr<r<r=�_splitnetloc�s
110  �r�cCs�|r|��rdSddl}|�dd�}|�dd�}|�dd�}|�dd�}|�d|�}||kr0dSdD]}||vrBtd	|d
111  d��q2dS)Nrr�rr�r��?�NFKCz/?#@:znetloc 'z' contains invalid z#characters under NFKC normalization)r~�unicodedata�replace�	normalizer�)r�r��n�netloc2r�r<r<r=�_checknetloc�s"���r�c
Cszt||�\}}}tD]}|�|d�}|�|d�}q
112  t|�}|||t|�t|�f}t�|d�}|r4||�Stt�tkr=t	�d}}}	|�
113  d�}
114  |
115  dkrl|d|
116  �D]}|tvrZnqR|d|
117  ���||
118  dd�}}|dd�dkr�t
|d�\}}d|vr�d	|vs�d	|vr�d|vr�td
119  ��|r�d|vr�|�dd�\}}	d|vr�|�dd�\}}t|�t|||||	�}|t|<||�S)
a�Parse a URL into 5 components:
120      <scheme>://<netloc>/<path>?<query>#<fragment>
121  
122      The result is a named 5-tuple with fields corresponding to the
123      above. It is either a SplitResult or SplitResultBytes object,
124      depending on the type of the url parameter.
125  
126      The username, password, hostname, and port sub-components of netloc
127      can also be accessed as attributes of the returned object.
128  
129      The scheme argument provides the default value of the scheme
130      component when no scheme is found in url.
131  
132      If allow_fragments is False, no attempt is made to separate the
133      fragment component from the previous component, which can be either
134      path or query.
135  
136      Note that % escapes are not expanded.
137      rNr�rrS��//r�r�zInvalid IPv6 URLr�r�)rY�_UNSAFE_URL_BYTES_TO_REMOVEr��bool�typer9�getr��MAX_CACHE_SIZEr>r��scheme_charsrxr�r��splitr�r)
r�r�r�r��b�key�cachedr�r�r�r�r��vr<r<r=r�s@
138  �"rcCs<t|�\}}}}}}}|rd||f}|t|||||f��S)z�Put a parsed URL back together again.  This may result in a
139      slightly different, but equivalent URL, if the URL that was parsed
140      originally had redundant delimiters, e.g. a ? with an empty query
141      (the draft states that these are equivalent).z%s;%s)rYr)�
142  componentsr�r�r�r�r�r�r�r<r<r=r�s
143  �rcCs�t|�\}}}}}}|s|r0|tvr0|dd�dkr0|r(|dd�dkr(d|}d|p,d|}|r8|d|}|r@|d|}|rH|d	|}||�S)
144  akCombine the elements of a tuple as returned by urlsplit() into a
145      complete URL as a string. The data argument can be any five-item iterable.
146      This may result in a slightly different, but equivalent URL, if the URL that
147      was parsed originally had unnecessary delimiters (for example, a ? with an
148      empty query; the RFC states that these are equivalent).Nr�r�rSr�rr�r�r�)rY�uses_netloc)r�r�r�r�r�r�r�r<r<r=r�s� rc	Cs�|s|S|s|St||�\}}}t|d|�\}}}}}}	t|||�\}
149  }}}
}}|
150  |ks0|
151  tvr4||�S|
152  tvrH|rF|t|
153  |||
||f��S|}|s`|
s`|}|}
|sT|}|t|
154  |||
||f��S|�d�}|ddkrn|d=|dd�dkr||�d�}n||�d�}td|dd��|dd�<g}|D] }|dkr�z|��Wq�ty�Yq�w|dkr�q�|�	|�q�|ddvr�|�	d�|t|
155  |d�
156  |�p�d|
||f��S)	zaJoin a base URL and a possibly relative URL to form an absolute
157      interpretation of the latter.rr������NrS�..�.)r�r�)rYr�
uses_relativer�rr��filter�pop�
158  IndexError�append�join)�baser�r�r��bscheme�bnetloc�bpath�bparams�bquery�	bfragmentr�r��pathr�r�r��
159  base_parts�segments�
resolved_path�segr<r<r=rsd
160  �
161  �
162  �
163  �
164  �
165  ��rc	CsTt|�\}}d|vrt|�\}}}}}}t|||||df�}nd}|}|t||��S)z�Removes any existing fragment from URL.
166  
167      Returns a tuple of the defragmented URL and the fragment.  If
168      the URL contained no fragments, the second element is the
169      empty string.
170      r�r)rYrrr)	r�r��sr��p�a�q�frag�defragr<r<r=rPsr�0123456789ABCDEFabcdefc	Cs�|s|jdSt|t�r|�d�}|�d�}t|�dkr|S|dg}|j}tdur1dd�tD�a|dd�D]'}z|t|dd	��||d	d��Wq7ty^|d�||�Yq7wd�	|�S)
171  z,unquote_to_bytes('abc%20def') -> b'abc def'.��utf-8rurSrNcSs.i|]}tD]}||��t�||��qqSr<)�_hexdigrE�bytes�fromhex)rLr�r�r<r<r=�
172  <dictcomp>vs
173  ��z$unquote_to_bytes.<locals>.<dictcomp>r�)
174  r�rTrUrEr�r��
175  _hextobyter��KeyErrorr�)�string�bits�resr��itemr<r<r=rcs.
176  
177  
178  
179  ��
180  rz([-]+)r�r�cCs�t|t�r
t|��||�Sd|vr|j|S|durd}|dur"d}t�|�}|dg}|j}tdt|�d�D]}|t||��||��|||d�q7d�	|�S)	a�Replace %xx escapes by their single-character equivalent. The optional
181      encoding and errors parameters specify how to decode percent-encoded
182      sequences into Unicode characters, as accepted by the bytes.decode()
183      method.
184      By default, percent-encoded sequences are decoded with UTF-8, and invalid
185      sequences are replaced by a placeholder character.
186  
187      unquote('abc%20def') -> 'abc def'.
188      rtNr�r�rrSr�r)
189  rTrrrJr��_asciirer��ranger�r�)rrFrGrrr�r�r<r<r=r�s 
190  
191  
192  
193  
194  rF�&c	CsNi}t|||||||d�}|D]\}	}
195  |	|vr||	�|
196  �q|
197  g||	<q|S)aXParse a query given as a string argument.
198  
199          Arguments:
200  
201          qs: percent-encoded query string to be parsed
202  
203          keep_blank_values: flag indicating whether blank values in
204              percent-encoded queries should be treated as blank strings.
205              A true value indicates that blanks should be retained as
206              blank strings.  The default false value indicates that
207              blank values are to be ignored and treated as if they were
208              not included.
209  
210          strict_parsing: flag indicating what to do with parsing errors.
211              If false (the default), errors are silently ignored.
212              If true, errors raise a ValueError exception.
213  
214          encoding and errors: specify how to decode percent-encoded sequences
215              into Unicode characters, as accepted by the bytes.decode() method.
216  
217          max_num_fields: int. If set, then throws a ValueError if there
218              are more than n fields read by parse_qsl().
219  
220          separator: str. The symbol to use for separating the query arguments.
221              Defaults to &.
222  
223          Returns a dictionary.
224      )rFrG�max_num_fieldsrz)r
225  r�)�qs�keep_blank_values�strict_parsingrFrGrrz�
parsed_result�pairs�name�valuer<r<r=r	�s�r	cCs t|�\}}t|�\}}|rt|ttf�std��|dur,d|�|�}	||	kr,td��g}
226  |�|�D]Z}|s:|s:q3|�dd�}t|�dkrX|rOtd|f��|rW|�d�nq3t|d�s`|r�|d	�	d
227  d�}
t
228  |
||d�}
||
�}
|d�	d
229  d�}t
230  |||d�}||�}|
231  �|
|f�q3|
232  S)
aXParse a query given as a string argument.
233  
234          Arguments:
235  
236          qs: percent-encoded query string to be parsed
237  
238          keep_blank_values: flag indicating whether blank values in
239              percent-encoded queries should be treated as blank strings.
240              A true value indicates that blanks should be retained as blank
241              strings.  The default false value indicates that blank values
242              are to be ignored and treated as if they were  not included.
243  
244          strict_parsing: flag indicating what to do with parsing errors. If
245              false (the default), errors are silently ignored. If true,
246              errors raise a ValueError exception.
247  
248          encoding and errors: specify how to decode percent-encoded sequences
249              into Unicode characters, as accepted by the bytes.decode() method.
250  
251          max_num_fields: int. If set, then throws a ValueError
252              if there are more than n fields read by parse_qsl().
253  
254          separator: str. The symbol to use for separating the query arguments.
255              Defaults to &.
256  
257          Returns a list, as G-d intended.
258      z*Separator must be of type string or bytes.NrSzMax number of fields exceeded�=r�zbad query field: %rrr�+� rN)rYrTrUrr��countr�r�r�r�r)r
rrrFrGrrzr�r��
259  num_fields�r�
260  name_value�nvrrr<r<r=r
261  �s:�r
262  cCs|�dd�}t|||�S)z�Like unquote(), but also replace plus signs by spaces, as required for
263      unquoting HTML form values.
264  
265      unquote_plus('%7e/abc+def') -> '~/abc def'
266      rr)r�r)rrFrGr<r<r=rsrsBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-~c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Quoterz�A mapping from bytes (in range(0,256)) to strings.
267  
268      String values are percent-encoded byte values, unless the key < 128, and
269      in the "safe" set (either the specified safe set, or default set).
270      cCst�|�|_dS)zsafe: bytes object.N)�_ALWAYS_SAFE�union�safe)rarr<r<r=�__init__#szQuoter.__init__cCsd|jjt|�fS)Nz<%s %r>)�	__class__rd�dictrpr<r<r=�__repr__'szQuoter.__repr__cCs(||jvr	t|�nd�|�}|||<|S)Nz%{:02X})r�chr�format)rar�rr<r<r=�__missing__+szQuoter.__missing__N)rdrerfrgr r#r&r<r<r<r=rs
271  rr�cCsbt|t�r|s	|S|durd}|durd}|�||�}n|dur$td��|dur,td��t||�S)a�quote('abc def') -> 'abc%20def'
272  
273      Each part of a URL, e.g. the path info, the query, etc., has a
274      different set of reserved characters that must be quoted. The
275      quote function offers a cautious (not minimal) way to quote a
276      string for most of these parts.
277  
278      RFC 3986 Uniform Resource Identifier (URI): Generic Syntax lists
279      the following (un)reserved characters.
280  
281      unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
282      reserved      = gen-delims / sub-delims
283      gen-delims    = ":" / "/" / "?" / "#" / "[" / "]" / "@"
284      sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
285                    / "*" / "+" / "," / ";" / "="
286  
287      Each of the reserved characters is reserved in some component of a URL,
288      but not necessarily in all of them.
289  
290      The quote function %-escapes all characters that are neither in the
291      unreserved chars ("always safe") nor the additional chars set via the
292      safe arg.
293  
294      The default for the safe arg is '/'. The character is reserved, but in
295      typical usage the quote function is being called on a path where the
296      existing slash characters are to be preserved.
297  
298      Python 3.7 updates from using RFC 2396 to RFC 3986 to quote URL strings.
299      Now, "~" is included in the set of unreserved characters.
300  
301      string and safe may be either str or bytes objects. encoding and errors
302      must not be specified if string is a bytes object.
303  
304      The optional encoding and errors parameters specify how to deal with
305      non-ASCII characters, as accepted by the str.encode method.
306      By default, encoding='utf-8' (characters are encoded with UTF-8), and
307      errors='strict' (unsupported characters raise a UnicodeEncodeError).
308      Nr�r@z,quote() doesn't support 'encoding' for bytesz*quote() doesn't support 'errors' for bytes)rTrUrErVr
)rrrFrGr<r<r=r1s
309  '
310  rcCsdt|t�r	d|vst|t�rd|vrt||||�St|t�r!d}nd}t|||||�}|�dd�S)z�Like quote(), but also replace ' ' with '+', as required for quoting
311      HTML form values. Plus signs in the original string are escaped unless
312      they are included in safe. It also does not have safe default to '/'.
313      r� r)rTrUrrr�)rrrFrG�spacer<r<r=rgs�
314  rcs�t|ttf�std��|sdSt|t�r|�dd�}n	tdd�|D��}|�t|�s/|��Szt	|�Wnt
315  yGt|�jt	|<�Ynwd�
�fdd�|D��S)z�Like quote(), but accepts a bytes object rather than a str, and does
316      not perform string-to-bytes encoding.  It always returns an ASCII string.
317      quote_from_bytes(b'abc def?') -> 'abc%20def%3f'
318      z!quote_from_bytes() expected bytesrr?�ignorecSsg|]}|dkr|�qS)�r<)rLr�r<r<r=�
319  <listcomp>�sz$quote_from_bytes.<locals>.<listcomp>csg|]}�|��qSr<r<)rL�char��quoterr<r=r+�s)rTr�	bytearrayrVrUrE�rstrip�_ALWAYS_SAFE_BYTESrJr;rr�__getitem__r�)�bsrr<r-r=r
xs
320  �r
c	Cs�t|d�r
321  |��}n%zt|�rt|dt�st�Wnty.t��\}}}td��|��wg}	|sl|D]5\}
322  }t|
323  t	�rD||
324  |�}
325  n	|t
326  |
327  �|||�}
328  t|t	�rX|||�}n	|t
329  |�|||�}|	�|
330  d|�q5n�|D]�\}
331  }t|
332  t	�r}||
333  |�}
334  n	|t
335  |
336  �|||�}
337  t|t	�r�|||�}|	�|
338  d|�qnt|t
339  �r�|||||�}|	�|
340  d|�qnzt|�}Wnty�|t
341  |�|||�}|	�|
342  d|�Yqnw|D]}
t|
t	�r�||
|�}
n	|t
343  |
�|||�}
|	�|
344  d|
�q�qnd�|	�S)a^Encode a dict or sequence of two-element tuples into a URL query string.
345  
346      If any values in the query arg are sequences and doseq is true, each
347      sequence element is converted to a separate parameter.
348  
349      If the query arg is a sequence of two-element tuples, the order of the
350      parameters in the output will match the order of parameters in the
351      input.
352  
353      The components of a query arg may each be either a string or a bytes type.
354  
355      The safe, encoding, and errors parameters are passed down to the function
356      specified by quote_via (encoding and errors only if a component is a str).
357      �itemsrz1not a valid non-string sequence or mapping objectrr)
�hasattrr4r�rTrPrV�sys�exc_info�with_tracebackrrUr�r�)r��doseqrrFrG�	quote_via�ty�va�tb�l�kr�rM�eltr<r<r=r�s\
358  
359  ���
360  
361  �
362  
363  
364  
365  �
366  �
367  rcC�tjdtdd�t|�S)Nz/urllib.parse.to_bytes() is deprecated as of 3.8r���
368  stacklevel)�warnings�warn�DeprecationWarning�	_to_bytes�r�r<r<r=�to_bytes�s�rIcCsFt|t�r!z
369  |�d���}W|Sty tdt|�d��w|S)zto_bytes(u"URL") --> 'URL'.�ASCIIzURL z contains non-ASCII characters)rTrUrErJ�UnicodeError�reprrHr<r<r=rG�s
370  ���rGcCs`t|���}|dd�dkr|dd�dkr|dd���}|dd�dkr.|dd���}|S)z�Transform a string like '<URL:scheme://host/path>' into 'scheme://host/path'.
371  
372      The string is returned unchanged if it's not a wrapped URL.
373      NrS�<r��>�zURL:)rU�striprHr<r<r=�unwrap�s rQcCrA)NzUurllib.parse.splittype() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr�rB)rDrErF�
374  _splittyperHr<r<r=�	splittype��rScCsDtdurt�dtj�at�|�}|r|��\}}|��|fSd|fS)z:splittype('type:opaquestring') --> 'type', 'opaquestring'.Nz
([^/:]+):(.*))�	_typeprog�re�compile�DOTALL�match�groupsrx)r�rYr��datar<r<r=rRs
375  rRcCrA)NzUurllib.parse.splithost() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr�rB)rDrErF�
376  _splithostrHr<r<r=�	splithostrTr]cCsXtdurt�dtj�at�|�}|r(|��\}}|r$|ddkr$d|}||fSd|fS)z;splithost('//host[:port]/path') --> 'host[:port]', '/path'.Nz//([^/#?]*)(.*)rr�)�	_hostprogrVrWrXrYrZ)r�rY�	host_portr�r<r<r=r\s
377  r\cCrA)NzUurllib.parse.splituser() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr�rB)rDrErF�
378  _splituser��hostr<r<r=�	splituser,rTrccCs$|�d�\}}}|r||fSd|fS)zJsplituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.r�N�r�)rb�userr�r<r<r=r`3sr`cCrA)NzWurllib.parse.splitpasswd() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr�rB)rDrErF�_splitpasswd)rer<r<r=�splitpasswd9rTrgcC�"|�d�\}}}||r|fSdfS)z/splitpasswd('user:passwd') -> 'user', 'passwd'.r�N�rw)rer��passwdr<r<r=rf@�rfcCrA)NzUurllib.parse.splitport() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr�rB)rDrErF�
379  _splitportrar<r<r=�	splitportFrTrmcCsDtdurt�dtj�at�|�}|r|��\}}|r||fS|dfS)z*splitport('host:port') --> 'host', 'port'.Nz
(.*):([0-9]*))�	_portprogrVrWrX�	fullmatchrZ)rbrYr�r<r<r=rlOs
380  rlr�cCstjdtdd�t||�S)NzVurllib.parse.splitnport() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr�rB)rDrErF�_splitnport)rb�defportr<r<r=�
381  splitnport]s�
382  rrcCsX|�d�\}}}|s|}||fS|r(|��r"|��r"t|�}||fSd}||fS||fS)z�Split host and port, returning numeric port.
383      Return given default port if no ':' found; defaults to -1.
384      Return numerical port if a valid number is found after ':'.
385      Return None if ':' but not a valid number.r�N)r�r}r~r)rbrqr�r��nportr<r<r=rpds��rpcCrA)NzVurllib.parse.splitquery() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr�rB)rDrErF�_splitqueryrHr<r<r=�
386  splitqueryurTrucC�$|�d�\}}}|r||fS|dfS)z/splitquery('/path?query') --> '/path', 'query'.r�Nrd)r�r�r�r�r<r<r=rt|�rtcCrA)NzTurllib.parse.splittag() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr�rB)rDrErF�	_splittagrHr<r<r=�splittag�rTrycCrv)z)splittag('/path#tag') --> '/path', 'tag'.r�Nrd)r�r�r��tagr<r<r=rx�rwrxcCrA)NzUurllib.parse.splitattr() is deprecated as of 3.8, use urllib.parse.urlparse() insteadr�rB)rDrErF�
387  _splitattrrHr<r<r=�	splitattr�rTr|cCs|�d�}|d|dd�fS)zksplitattr('/path;attr1=value1;attr2=value2;...') ->
388          '/path', ['attr1=value1', 'attr2=value2', ...].r�rrSN)r�)r��wordsr<r<r=r{�s
389  r{cCrA)NzWurllib.parse.splitvalue() is deprecated as of 3.8, use urllib.parse.parse_qsl() insteadr�rB)rDrErF�_splitvalue)�attrr<r<r=�
390  splitvalue�rTr�cCrh)z-splitvalue('attr=value') --> 'attr', 'value'.rNri)rr�rr<r<r=r~�rkr~)rT)r)T)r�r�)FFr�r�Nr)r�NN)rNN)r�)r�)hrgrVr6r��collectionsrD�__all__r�r�r��non_hierarchical�
391  uses_query�
uses_fragmentr�r�r�r9r>�_implicit_encoding�_implicit_errorsrCrHrRrY�objectr[rjrlr�r�r��_DefragResultBase�_SplitResultBase�_ParseResultBaser�r�r�r�r�r�r��
392  ResultBaserrrrrrr�rr�r�r�rrrrrr�rrrWr	rr	r
393  r�	frozensetrrr1r;�defaultdictrrrr
rrIrGrQrSrUrRr]r^r\rcr`rgrfrmrnrlrrrprurtryrxr|r{r�r~r<r<r<r=�<module>s�
394  �
395  �&
396  ��
397  
398  
399  	
400  9
401  E
402  
403  
404  �*
405406  B	
407  
408  6
409  
410  �Q


411  
412