HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/httpx/__pycache__/_urls.cpython-310.pyc
o

���g.T�@s�ddlmZddlZddlmZmZmZddlZddlm	Z	ddl
mZddlm
Z
dd	gZGd
d�d�ZGdd	�d	ejeef�ZdS)�)�annotationsN)�parse_qs�unquote�	urlencode�)�QueryParamTypes)�urlparse��primitive_value_to_str�URL�QueryParamsc@sreZdZdZdNdOd	d
�ZedPdd
��ZedQdd��ZedQdd��ZedPdd��Z	edPdd��Z
edPdd��ZedQdd��ZedRdd��Z
edQdd��ZedPd d!��ZedQd"d#��ZedSd%d&��ZedQd'd(��ZedPd)d*��ZedTd,d-��ZedTd.d/��ZdUd0d1�ZdVdWd5d6�ZdVdWd7d8�ZdXd9d:�ZdYd=d>�ZdZd?d@�Zd[dBdC�Zd\dEdF�ZdPdGdH�ZdPdIdJ�Zed]dLdM��Z d2S)^ru(

    url = httpx.URL("HTTPS://jo%40email.com:a%20secret@müller.de:1234/pa%20th?search=ab#anchorlink")

    assert url.scheme == "https"
    assert url.username == "jo@email.com"
    assert url.password == "a secret"
    assert url.userinfo == b"jo%40email.com:a%20secret"
    assert url.host == "müller.de"
    assert url.raw_host == b"xn--mller-kva.de"
    assert url.port == 1234
    assert url.netloc == b"xn--mller-kva.de:1234"
    assert url.path == "/pa th"
    assert url.query == b"?search=ab"
    assert url.raw_path == b"/pa%20th?search=ab"
    assert url.fragment == "anchorlink"

    The components of a URL are broken down like this:

       https://jo%40email.com:a%20secret@müller.de:1234/pa%20th?search=ab#anchorlink
    [scheme]   [  username  ] [password] [ host ][port][ path ] [ query ] [fragment]
               [       userinfo        ] [   netloc   ][    raw_path    ]

    Note that:

    * `url.scheme` is normalized to always be lowercased.

    * `url.host` is normalized to always be lowercased. Internationalized domain
      names are represented in unicode, without IDNA encoding applied. For instance:

      url = httpx.URL("http://中国.icom.museum")
      assert url.host == "中国.icom.museum"
      url = httpx.URL("http://xn--fiqs8s.icom.museum")
      assert url.host == "中国.icom.museum"

    * `url.raw_host` is normalized to always be lowercased, and is IDNA encoded.

      url = httpx.URL("http://中国.icom.museum")
      assert url.raw_host == b"xn--fiqs8s.icom.museum"
      url = httpx.URL("http://xn--fiqs8s.icom.museum")
      assert url.raw_host == b"xn--fiqs8s.icom.museum"

    * `url.port` is either None or an integer. URLs that include the default port for
      "http", "https", "ws", "wss", and "ftp" schemes have their port
      normalized to `None`.

      assert httpx.URL("http://example.com") == httpx.URL("http://example.com:80")
      assert httpx.URL("http://example.com").port is None
      assert httpx.URL("http://example.com:80").port is None

    * `url.userinfo` is raw bytes, without URL escaping. Usually you'll want to work
      with `url.username` and `url.password` instead, which handle the URL escaping.

    * `url.raw_path` is raw bytes of both the path and query, without URL escaping.
      This portion is used as the target when constructing HTTP requests. Usually you'll
      want to work with `url.path` instead.

    * `url.query` is raw bytes, without URL escaping. A URL query string portion can
      only be properly URL escaped when decoding the parameter names and values
      themselves.
    ��url�	URL | str�kwargs�
typing.Any�return�Nonec

Ks2|rlttttttttttttd�}|��D]A\}}||vr&|�d�}t|��|durJt|||�sJ||j}t|�j}d|�d|�d|��}t|��t|t�rV|�	d�||<qd|vrl|�
d�}	|	sddntt|	��|d<t|t�r|t|fi|��|_
dSt|t�r�|j
jdi|��|_
dStd	t|��d
|����)N)�scheme�username�password�userinfo�host�port�netloc�path�query�raw_path�fragment�paramsz) is an invalid keyword argument for URL()z	Argument z	 must be z	 but got �asciirrz6Invalid type for url.  Expected str or httpx.URL, got z: �)�str�bytes�int�object�items�	TypeError�
isinstance�__name__�type�decode�poprr�_uri_referencer�	copy_with)
�selfrr�allowed�key�value�message�expected�seenrr!r!�6/usr/local/lib/python3.10/dist-packages/httpx/_urls.py�__init__MsP�



�


���zURL.__init__r"cC�|jjS)zb
        The URL scheme, such as "http", "https".
        Always normalised to lowercase.
        )r-r�r/r!r!r6r~�z
URL.schemer#cC�|jj�d�S)z�
        The raw bytes representation of the URL scheme, such as b"http", b"https".
        Always normalised to lowercase.
        r )r-r�encoder9r!r!r6�
raw_scheme��zURL.raw_schemecCr;)zj
        The URL userinfo as a raw bytestring.
        For example: b"jo%40email.com:a%20secret".
        r )r-rr<r9r!r!r6r�r>zURL.userinfocC�|jj}t|�d�d�S)zn
        The URL username as a string, with URL decoding applied.
        For example: "jo@email.com"
        �:r�r-rr�	partition�r/rr!r!r6r��zURL.usernamecCr?)zj
        The URL password as a string, with URL decoding applied.
        For example: "a secret"
        r@�rArCr!r!r6r�rDzURL.passwordcCs |jj}|�d�rt�|�}|S)u%
        The URL host as a string.
        Always normalized to lowercase, with IDNA hosts decoded into unicode.

        Examples:

        url = httpx.URL("http://www.EXAMPLE.org")
        assert url.host == "www.example.org"

        url = httpx.URL("http://中国.icom.museum")
        assert url.host == "中国.icom.museum"

        url = httpx.URL("http://xn--fiqs8s.icom.museum")
        assert url.host == "中国.icom.museum"

        url = httpx.URL("https://[::ffff:192.168.0.1]")
        assert url.host == "::ffff:192.168.0.1"
        zxn--)r-r�
startswith�idnar+)r/rr!r!r6r�s

zURL.hostcCr;)uA
        The raw bytes representation of the URL host.
        Always normalized to lowercase, and IDNA encoded.

        Examples:

        url = httpx.URL("http://www.EXAMPLE.org")
        assert url.raw_host == b"www.example.org"

        url = httpx.URL("http://中国.icom.museum")
        assert url.raw_host == b"xn--fiqs8s.icom.museum"

        url = httpx.URL("http://xn--fiqs8s.icom.museum")
        assert url.raw_host == b"xn--fiqs8s.icom.museum"

        url = httpx.URL("https://[::ffff:192.168.0.1]")
        assert url.raw_host == b"::ffff:192.168.0.1"
        r )r-rr<r9r!r!r6�raw_host�szURL.raw_host�
int | NonecCr8)a�
        The URL port as an integer.

        Note that the URL class performs port normalization as per the WHATWG spec.
        Default ports for "http", "https", "ws", "wss", and "ftp" schemes are always
        treated as `None`.

        For example:

        assert httpx.URL("http://www.example.com") == httpx.URL("http://www.example.com:80")
        assert httpx.URL("http://www.example.com:80").port is None
        )r-rr9r!r!r6r�szURL.portcCr;)z�
        Either `<host>` or `<host>:<port>` as bytes.
        Always normalized to lowercase, and IDNA encoded.

        This property may be used for generating the value of a request
        "Host" header.
        r )r-rr<r9r!r!r6r�s	z
URL.netloccCs|jjpd}t|�S)z�
        The URL path as a string. Excluding the query string, and URL decoded.

        For example:

        url = httpx.URL("https://example.com/pa%20th")
        assert url.path == "/pa th"
        �/)r-rr�r/rr!r!r6r�s
zURL.pathcCs|jjpd}|�d�S)a�
        The URL query string, as raw bytes, excluding the leading b"?".

        This is necessarily a bytewise interface, because we cannot
        perform URL decoding of this representation until we've parsed
        the keys and values into a QueryParams instance.

        For example:

        url = httpx.URL("https://example.com/?filter=some%20search%20terms")
        assert url.query == b"filter=some%20search%20terms"
        r
r )r-rr<)r/rr!r!r6rs
z	URL.queryrcCst|jj�S)zz
        The URL query parameters, neatly parsed and packaged into an immutable
        multidict representation.
        )rr-rr9r!r!r6rsz
URL.paramscCs2|jjpd}|jjdur|d|jj7}|�d�S)a
        The complete URL path and query string as raw bytes.
        Used as the target when constructing HTTP requests.

        For example:

        GET /users?search=some%20text HTTP/1.1
        Host: www.example.org
        Connection: close
        rJN�?r )r-rrr<rKr!r!r6rs
zURL.raw_pathcCst|jjpd�S)zk
        The URL fragments, as used in HTML anchors.
        As a string, without the leading '#'.
        r
)rr-rr9r!r!r6r+szURL.fragment�boolcCst|jjo|jj�S)z�
        Return `True` for absolute URLs such as 'http://example.com/path',
        and `False` for relative URLs such as '/path'.
        )rMr-rrr9r!r!r6�is_absolute_url3s
zURL.is_absolute_urlcCs|jS)z�
        Return `False` for absolute URLs such as 'http://example.com/path',
        and `True` for relative URLs such as '/path'.
        )rNr9r!r!r6�is_relative_url?r:zURL.is_relative_urlcKst|fi|��S)a�
        Copy this URL, returning a new URL with some components altered.
        Accepts the same set of parameters as the components that are made
        available via properties on the `URL` class.

        For example:

        url = httpx.URL("https://www.example.com").copy_with(
            username="jo@gmail.com", password="a secret"
        )
        assert url == "https://jo%40email.com:a%20secret@www.example.com"
        )r)r/rr!r!r6r.Gs
z
URL.copy_withNr1r2cC�|j|j�||�d�S�N)r)r.r�set�r/r1r2r!r!r6�copy_set_paramV�zURL.copy_set_paramcCrPrQ)r.r�addrSr!r!r6�copy_add_paramYrUzURL.copy_add_paramcC�|j|j�|�d�SrQ)r.r�remove�r/r1r!r!r6�copy_remove_param\�zURL.copy_remove_paramrrcCrXrQ)r.r�merge�r/rr!r!r6�copy_merge_params_r\zURL.copy_merge_paramscCs&ddlm}t|t|�tt|����S)z�
        Return an absolute URL, using this URL as the base.

        Eg.

        url = httpx.URL("https://www.example.com/test")
        url = url.join("/new/path")
        assert url == "https://www.example.com/new/path"
        r)�urljoin)�urllib.parser`rr")r/rr`r!r!r6�joinbs
zURL.joinr$cC�tt|��S�N��hashr"r9r!r!r6�__hash__p�zURL.__hash__�othercCs"t|ttf�ot|�tt|��kSrd)r(rr"�r/rir!r!r6�__eq__ss"z
URL.__eq__cC�
t|j�Srd)r"r-r9r!r!r6�__str__v�
zURL.__str__c
Cs�|j\}}}}}}}d|vr|�d�d�d�}d�|r!|�d�ndd|vr,d|�d�n||dur6d|��ndg�}d�|rD|j�d�nd|rLd|��nd||durWd	|��nd|durad
|��ndg�}	|jj�d|	�d�S)
Nr@rz	:[secure]r
�@�[�]z//rL�#�(�))r-�splitrbr�	__class__r))
r/rrrrrrr�	authorityrr!r!r6�__repr__ys$����
zURL.__repr__�tuple[bytes, bytes, int, bytes]cCsBddl}ddl}|�d�|�dgd��}||j|j|j|jd�S)NrzURL.raw is deprecated.�RawURL)r=rHrr)�collections�warnings�warn�
namedtupler=rHrr)r/r{r|rzr!r!r6�raw�s
��zURL.raw)r
)rrrrrr�rr")rr#)rrI)rr�rrM)rrrrrd)r1r"r2rrr)r1r"rr)rrrr)rrrr�rr$�rirrrM)rry)!r)�
__module__�__qualname__�__doc__r7�propertyrr=rrrrrHrrrrrrrrNrOr.rTrWr[r_rbrgrkrmrxrr!r!r!r6rs^=1








c@s�eZdZdZdCdd	�ZdDdd�ZdEdd�ZdFdd�ZdGdd�ZdHdIdd�Z	dJdd�Z
dHdKd d!�ZdHdKd"d#�ZdLd$d%�Z
dHdMd'd(�ZdNd)d*�ZdOd,d-�ZdPd/d0�ZdQd2d3�ZdRd4d5�ZdQd6d7�ZdSd9d:�ZdTd;d<�ZdTd=d>�ZdHdUd?d@�ZdVdAdB�ZdS)Wrz0
    URL query parameters, as a multi-dict.
    �args�QueryParamTypes | NonerrrrcOs�t|�dks
Jd��|r|rJd��|r|dn|}|dus%t|ttf�r:t|t�r/|�d�n|}t|dd�|_dSt|t�rLdd	�|j��D�|_dSi}t|t	t
f�rh|D]}|�|dg��|d
�qWn	dd	�|��D�}dd	�|��D�|_dS)
NrEzToo many arguments.z'Cannot mix named and unnamed arguments.rr T)�keep_blank_valuescSsi|]	\}}|t|��qSr!)�list��.0�k�vr!r!r6�
<dictcomp>��z(QueryParams.__init__.<locals>.<dictcomp>rcSs.i|]\}}|t|ttf�rt|�n|g�qSr!)r(r��tupler�r!r!r6r��s��cSs$i|]\}}t|�dd�|D��qS)cSsg|]}t|��qSr!r	)r��itemr!r!r6�
<listcomp>��z3QueryParams.__init__.<locals>.<dictcomp>.<listcomp>)r"r�r!r!r6r��s��)
�lenr(r"r#r+r�_dictrr&r�r��
setdefault�append)r/r�rr2�
dict_valuer�r!r!r6r7�s&
���zQueryParams.__init__�typing.KeysView[str]cCs
|j��S)z�
        Return all the keys in the query params.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert list(q.keys()) == ["a", "b"]
        )r��keysr9r!r!r6r��s
	zQueryParams.keys�typing.ValuesView[str]cCsdd�|j��D���S)a
        Return all the values in the query params. If a key occurs more than once
        only the first item for that key is returned.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert list(q.values()) == ["123", "789"]
        cS�i|]	\}}||d�qS�rr!r�r!r!r6r��r�z&QueryParams.values.<locals>.<dictcomp>)r�r&�valuesr9r!r!r6r���
zQueryParams.values�typing.ItemsView[str, str]cCsdd�|j��D���S)a
        Return all items in the query params. If a key occurs more than once
        only the first item for that key is returned.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert list(q.items()) == [("a", "123"), ("b", "789")]
        cSr�r�r!r�r!r!r6r��r�z%QueryParams.items.<locals>.<dictcomp>)r�r&r9r!r!r6r&�r�zQueryParams.items�list[tuple[str, str]]cs4g}|j��D]\�}|��fdd�|D��q|S)z�
        Return all items in the query params. Allow duplicate keys to occur.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert list(q.multi_items()) == [("a", "123"), ("a", "456"), ("b", "789")]
        csg|]}�|f�qSr!r!)r��i�r�r!r6r��r�z+QueryParams.multi_items.<locals>.<listcomp>)r�r&�extend)r/�multi_itemsr�r!r�r6r��s	zQueryParams.multi_itemsNr1�defaultcCs ||jvr|jt|�dS|S)z�
        Get a value from the query param for a given key. If the key occurs
        more than once, then only the first value is returned.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert q.get("a") == "123"
        r)r�r")r/r1r�r!r!r6�gets

zQueryParams.getr"�	list[str]cCst|j�t|�g��S)z�
        Get all values from the query param for a given key.

        Usage:

        q = httpx.QueryParams("a=123&a=456&b=789")
        assert q.get_list("a") == ["123", "456"]
        )r�r�r�r"rZr!r!r6�get_lists	zQueryParams.get_listr2cCs*t�}t|j�|_t|�g|jt|�<|S)z�
        Return a new QueryParams instance, setting the value of a key.

        Usage:

        q = httpx.QueryParams("a=123")
        q = q.set("a", "456")
        assert q == httpx.QueryParams("a=456")
        )r�dictr�r
r"�r/r1r2�qr!r!r6rRs
zQueryParams.setcCs4t�}t|j�|_|�|�t|�g|jt|�<|S)z�
        Return a new QueryParams instance, setting or appending the value of a key.

        Usage:

        q = httpx.QueryParams("a=123")
        q = q.add("a", "456")
        assert q == httpx.QueryParams("a=123&a=456")
        )rr�r�r�r
r"r�r!r!r6rV(s
zQueryParams.addcCs(t�}t|j�|_|j�t|�d�|S)z�
        Return a new QueryParams instance, removing the value of a key.

        Usage:

        q = httpx.QueryParams("a=123")
        q = q.remove("a")
        assert q == httpx.QueryParams("")
        N)rr�r�r,r")r/r1r�r!r!r6rY7s
zQueryParams.removercCst|�}i|j�|j�|_|S)a\
        Return a new QueryParams instance, updated with.

        Usage:

        q = httpx.QueryParams("a=123")
        q = q.merge({"b": "456"})
        assert q == httpx.QueryParams("a=123&b=456")

        q = httpx.QueryParams("a=123")
        q = q.merge({"a": "456", "b": "789"})
        assert q == httpx.QueryParams("a=456&b=789")
        )rr�)r/rr�r!r!r6r]FszQueryParams.mergecCs|j|dS)Nr�r�rZr!r!r6�__getitem__XszQueryParams.__getitem__rMcCs
||jvSrdr�rZr!r!r6�__contains__[rnzQueryParams.__contains__�typing.Iterator[typing.Any]cC�t|���Srd)�iterr�r9r!r!r6�__iter__^rhzQueryParams.__iter__r$cCrlrd)r�r�r9r!r!r6�__len__arnzQueryParams.__len__cCrlrd)rMr�r9r!r!r6�__bool__drnzQueryParams.__bool__cCrcrdrer9r!r!r6rggrhzQueryParams.__hash__ricCs(t||j�sdSt|���t|���kS)NF)r(rv�sortedr�rjr!r!r6rkjszQueryParams.__eq__cCr�rd)rr�r9r!r!r6rmorhzQueryParams.__str__cCs |jj}t|�}|�d|�d�S)Nrsrt)rvr)r")r/�
class_name�query_stringr!r!r6rxrszQueryParams.__repr__cC�td��)NzYQueryParams are immutable since 0.18.0. Use `q = q.merge(...)` to create an updated copy.��RuntimeErrorr^r!r!r6�updatew��zQueryParams.updatecCr�)Nz^QueryParams are immutable since 0.18.0. Use `q = q.set(key, value)` to create an updated copy.r�rSr!r!r6�__setitem__}r�zQueryParams.__setitem__)r�r�rrrr)rr�)rr�)rr�)rr�rd)r1rr�rrr)r1r"rr�)r1r"r2rrr)r1r"rr)rr�rr)r1rrr")r1rrrM)rr�r�r�r�r�)rr�rr)r1r"r2r"rr)r)r�r�r�r7r�r�r&r�r�r�rRrVrYr]r�r�r�r�r�rgrkrmrxr�r�r!r!r!r6r�s0

&













)�
__future__r�typingrarrrrG�_typesr�	_urlparser�_utilsr
�__all__r�Mappingr"rr!r!r!r6�<module>s