
    ,h.T                        d dl mZ d dlZd dlmZmZmZ d dlZddlm	Z	 ddl
mZ ddlmZ dd	gZ G d
 d      Z G d d	ej                   eef         Zy)    )annotationsN)parse_qsunquote	urlencode   )QueryParamTypes)urlparse)primitive_value_to_strURLQueryParamsc                     e Zd ZdZdd dZed!d       Zed"d       Zed"d       Zed!d       Z	ed!d       Z
ed!d       Zed"d	       Zed#d
       Zed"d       Zed!d       Zed"d       Zed$d       Zed"d       Zed!d       Zed%d       Zed%d       Zd&dZd'd(dZd'd(dZd)dZd*dZd+dZd,dZd-dZd!dZd!dZed.d       Z y)/r   u(
  
    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.
    c                   |rt         t         t         t        t         t        t        t         t        t        t         t        d}|j	                         D ]  \  }}||vr|d}t        |      |It        |||         s:||   j                  }t        |      j                  }d|d| d| }t        |      t        |t              sv|j                  d      ||<    d|v r,|j                  d      }	|	sd nt        t        |	            |d<   t        |t               rt        |fi || _        y t        |t              r" |j                  j                  di || _        y t        d	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 asciir   r   z6Invalid 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)
selfurlkwargsallowedkeyvaluemessageexpectedseenr   s
             M/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/httpx/_urls.py__init__zURL.__init__M   sv   !! G  %lln 
8
Ug%!$'PQG#G,,$Zws|-L&s|44H;//D )#	(9TFSG#G,,eU+"',,w"7F3K
8 6!  H-.4$#k&>Q:Rwc3"*3"9&"9DS!">#"4"4">">"H"HDS	{"SG-     c                .    | j                   j                  S )zb
        The URL scheme, such as "http", "https".
        Always normalised to lowercase.
        )r(   r   r*   s    r3   r   z
URL.scheme~   s     "")))r5   c                L    | j                   j                  j                  d      S )z
        The raw bytes representation of the URL scheme, such as b"http", b"https".
        Always normalised to lowercase.
        r   )r(   r   encoder7   s    r3   
raw_schemezURL.raw_scheme   s!     ""))0099r5   c                L    | j                   j                  j                  d      S )zj
        The URL userinfo as a raw bytestring.
        For example: b"jo%40email.com:a%20secret".
        r   )r(   r   r9   r7   s    r3   r   zURL.userinfo   s!     ""++227;;r5   c                h    | j                   j                  }t        |j                  d      d         S )zn
        The URL username as a string, with URL decoding applied.
        For example: "jo@email.com"
        :r   r(   r   r   	partitionr*   r   s     r3   r   zURL.username   0     &&//x))#.q122r5   c                h    | j                   j                  }t        |j                  d      d         S )zj
        The URL password as a string, with URL decoding applied.
        For example: "a secret"
        r=      r>   r@   s     r3   r   zURL.password   rA   r5   c                ~    | j                   j                  }|j                  d      rt        j                  |      }|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"
        zxn--)r(   r   
startswithidnar&   )r*   r   s     r3   r   zURL.host   s4    ( '',,??6";;t$Dr5   c                L    | j                   j                  j                  d      S )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(   r   r9   r7   s    r3   raw_hostzURL.raw_host   s!    ( ""''..w77r5   c                .    | j                   j                  S )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(   r   r7   s    r3   r   zURL.port   s     ""'''r5   c                L    | j                   j                  j                  d      S )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(   r   r9   r7   s    r3   r   z
URL.netloc   s!     ""))0099r5   c                L    | j                   j                  xs d}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(   r   r   r*   r   s     r3   r   zURL.path   s$     ""''.3t}r5   c                X    | j                   j                  xs d}|j                  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   r9   )r*   r   s     r3   r   z	URL.query  s)     ##))/R||G$$r5   c                @    t        | j                  j                        S )zz
        The URL query parameters, neatly parsed and packaged into an immutable
        multidict representation.
        )r   r(   r   r7   s    r3   r   z
URL.params  s     4..4455r5   c                    | j                   j                  xs d}| j                   j                  |d| j                   j                  z   z  }|j                  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
        rL   ?r   )r(   r   r   r9   rM   s     r3   r   zURL.raw_path  sV     ""''.3$$0C$--3333D{{7##r5   c                H    t        | j                  j                  xs d      S )zk
        The URL fragments, as used in HTML anchors.
        As a string, without the leading '#'.
        rO   )r   r(   r   r7   s    r3   r   zURL.fragment+  s      t**339r::r5   c                p    t        | j                  j                  xr | j                  j                        S )z
        Return `True` for absolute URLs such as 'http://example.com/path',
        and `False` for relative URLs such as '/path'.
        )boolr(   r   r   r7   s    r3   is_absolute_urlzURL.is_absolute_url3  s,     D''..K43F3F3K3KLLr5   c                    | j                    S )z
        Return `False` for absolute URLs such as 'http://example.com/path',
        and `True` for relative URLs such as '/path'.
        )rV   r7   s    r3   is_relative_urlzURL.is_relative_url?  s     ''''r5   c                    t        | fi |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*   r,   s     r3   r)   zURL.copy_withG  s     4"6""r5   Nc                Z    | j                  | j                  j                  ||            S N)r   )r)   r   setr*   r.   r/   s      r3   copy_set_paramzURL.copy_set_paramV  "    ~~T[[__S%%@~AAr5   c                Z    | j                  | j                  j                  ||            S r[   )r)   r   addr]   s      r3   copy_add_paramzURL.copy_add_paramY  r_   r5   c                X    | j                  | j                  j                  |            S r[   )r)   r   remover*   r.   s     r3   copy_remove_paramzURL.copy_remove_param\  s"    ~~T[[%7%7%<~==r5   c                X    | j                  | j                  j                  |            S r[   )r)   r   merger*   r   s     r3   copy_merge_paramszURL.copy_merge_params_  s"    ~~T[[%6%6v%>~??r5   c           
     h    ddl m} t         |t        |       t        t        |                        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.parserl   r   r   )r*   r+   rl   s      r3   joinzURL.joinb  s%     	)73t9c#c(m455r5   c                *    t        t        |             S Nhashr   r7   s    r3   __hash__zURL.__hash__p      CIr5   c                r    t        |t        t        f      xr  t        |       t        t        |            k(  S rp   )r#   r   r   r*   others     r3   __eq__z
URL.__eq__s  s)    %#s,MTc#e*o1MMr5   c                ,    t        | j                        S rp   )r   r(   r7   s    r3   __str__zURL.__str__v  s    4&&''r5   c                h   | j                   \  }}}}}}}d|v r|j                  d      d    d}dj                  |r| dndd|v rd| dn||d| ndg      }dj                  |r| j                   dnd|rd| nd||d	| nd|d
| ndg      }	| j                  j
                   d|	dS )Nr=   r   z	:[secure]rO   @[]z//rR   #())r(   splitrn   r   	__class__r$   )
r*   r   r   r   r   r   r   r   	authorityr+   s
             r3   __repr__zURL.__repr__y  s    >B>Q>Q;$dE8(?"..-a01;HGG"*8*A"d{!D6".!D6
B
	 gg%+4;;-q!$-"YK 2$0!E7b"*"6!H:B
 ..))*!C7!44r5   c                    dd l }dd l}|j                  d       |j                  dg d      } || j                  | j
                  | j                  | j                        S )Nr   zURL.raw is deprecated.RawURL)r:   rH   r   r   )collectionswarningswarn
namedtupler:   rH   r   r   )r*   r   r   r   s       r3   rawzURL.raw  sV    ./''D
 ]]]]	
 	
r5   )rO   )r+   	URL | strr,   
typing.AnyreturnNoner   r   )r   r   )r   z
int | None)r   r   r   rU   )r,   r   r   r   rp   )r.   r   r/   r   r   r   )r.   r   r   r   )r   r   r   r   )r+   r   r   r   r   r   rw   r   r   rU   )r   ztuple[bytes, bytes, int, bytes])!r$   
__module____qualname____doc__r4   propertyr   r:   r   r   r   r   rH   r   r   r   r   r   r   r   rV   rX   r)   r^   rb   rf   rj   rn   rs   rx   rz   r   r   r   r5   r3   r   r      s   ;z/b * * : : < < 3 3 3 3  4 8 8* ( ( : : 
 
 % %  6 6 $ $  ; ; 	M 	M ( (#BB>@6N(54 
 
r5   c                      e Zd ZdZddZddZddZddZddZdddZ	d d	Z
dd!d
Zdd!dZd"dZdd#dZd$dZd%dZd&dZd'dZd(dZd'dZd)dZd*dZd*dZdd+dZd,dZy)-r   z0
    URL query parameters, as a multi-dict.
    c                j   t        |      dk  sJ d       |r	|rJ d       |r|d   n|}|t        |t        t        f      r6t        |t              r|j	                  d      n|}t        |d      | _        y t        |t              r=|j                  j                         D ci c]  \  }}|t        |       c}}| _        y i }t        |t        t        f      r/|D ])  }|j                  |d   g       j                  |d          + nE|j                         D ci c]*  \  }}|t        |t        t        f      rt        |      n|g, }}}|j                         D ci c](  \  }}t        |      |D cg c]  }t        |       c}* c}}}| _        y c c}}w c c}}w c c}w c c}}}w )	NrC   zToo many arguments.z'Cannot mix named and unnamed arguments.r   r   T)keep_blank_valuesr   )lenr#   r   r   r&   r   _dictr   r!   listtuple
setdefaultappendr
   )r*   argsr,   r/   kv
dict_valueitems           r3   r4   zQueryParams.__init__  s   4y1}333VO&OOQV=JusEl;-7u-EELL)5E!%4@DJ{+161B1B1DEA!T!W*EDJ=?J%$/
 " GD))$q'26==d1gFG !&1 *Qu">tAwQCG
  ',,. Aq A!D$/5DDDJ/ F Es$   %F/F#%F.;F)F.)F.c                6    | j                   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   keysr7   s    r3   r   zQueryParams.keys  s     zz  r5   c                    | j                   j                         D ci c]  \  }}||d    c}}j                         S c c}}w )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"]
        r   )r   r!   valuesr*   r   r   s      r3   r   zQueryParams.values  s:     %)JJ$4$4$67DAq1Q47>>@@7   A c                    | j                   j                         D ci c]  \  }}||d    c}}j                         S c c}}w )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")]
        r   )r   r!   r   s      r3   r!   zQueryParams.items  s:     %)JJ$4$4$67DAq1Q47==??7r   c                    g }| j                   j                         D ]&  \  }}|j                  |D cg c]  }||f c}       ( |S c c}w )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")]
        )r   r!   extend)r*   multi_itemsr   r   is        r3   r   zQueryParams.multi_items  sQ     .0JJ$$& 	4DAq21A23	4  3s   A
Nc                X    || j                   v r| j                   t        |         d   S |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*   r.   defaults      r3   getzQueryParams.get   s-     $**::c#h'**r5   c                ^    t        | j                  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   re   s     r3   get_listzQueryParams.get_list  s"     DJJNN3s8R011r5   c                    t               }t        | j                        |_        t        |      g|j                  t	        |      <   |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*   r.   r/   qs       r3   r\   zQueryParams.set  s:     Mtzz"3E:;Cr5   c                    t               }t        | j                        |_        |j                  |      t	        |      gz   |j                  t        |      <   |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   s       r3   ra   zQueryParams.add(  sH     Mtzz"JJsO/Ee/L.MMCr5   c                    t               }t        | j                        |_        |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*   r.   r   s      r3   rd   zQueryParams.remove7  s6     Mtzz"	CHd#r5   c                Z    t        |      }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*   r   r   s      r3   rh   zQueryParams.mergeF  s,     +TZZ+177+r5   c                &    | j                   |   d   S )Nr   r   re   s     r3   __getitem__zQueryParams.__getitem__X  s    zz#q!!r5   c                    || j                   v S rp   r   re   s     r3   __contains__zQueryParams.__contains__[  s    djj  r5   c                4    t        | j                               S rp   )iterr   r7   s    r3   __iter__zQueryParams.__iter__^  s    DIIK  r5   c                ,    t        | j                        S rp   )r   r   r7   s    r3   __len__zQueryParams.__len__a  s    4::r5   c                ,    t        | j                        S rp   )rU   r   r7   s    r3   __bool__zQueryParams.__bool__d  s    DJJr5   c                *    t        t        |             S rp   rq   r7   s    r3   rs   zQueryParams.__hash__g  rt   r5   c                    t        || j                        syt        | j                               t        |j                               k(  S )NF)r#   r   sortedr   rv   s     r3   rx   zQueryParams.__eq__j  s:    %0d&&()VE4E4E4G-HHHr5   c                4    t        | j                               S rp   )r   r   r7   s    r3   rz   zQueryParams.__str__o  s    ))+,,r5   c                T    | j                   j                  }t        |       }| d|dS )Nr   r   )r   r$   r   )r*   
class_namequery_strings      r3   r   zQueryParams.__repr__r  s.    ^^,,
4yQ|.a00r5   c                    t        d      )NzYQueryParams are immutable since 0.18.0. Use `q = q.merge(...)` to create an updated copy.RuntimeErrorri   s     r3   updatezQueryParams.updatew  s    @
 	
r5   c                    t        d      )Nz^QueryParams are immutable since 0.18.0. Use `q = q.set(key, value)` to create an updated copy.r   r]   s      r3   __setitem__zQueryParams.__setitem__}  s    E
 	
r5   )r   QueryParamTypes | Noner,   r   r   r   )r   ztyping.KeysView[str])r   ztyping.ValuesView[str])r   ztyping.ItemsView[str, str])r   zlist[tuple[str, str]]rp   )r.   r   r   r   r   r   )r.   r   r   z	list[str])r.   r   r/   r   r   r   )r.   r   r   r   )r   r   r   r   )r.   r   r   r   )r.   r   r   rU   )r   ztyping.Iterator[typing.Any]r   r   r   r   )r   r   r   r   )r.   r   r/   r   r   r   )r$   r   r   r   r4   r   r   r!   r   r   r   r\   ra   rd   rh   r   r   r   r   r   rs   rx   rz   r   r   r   r   r5   r3   r   r     sy    $L	!
A
@	2$"!! I
-1


r5   )
__future__r   typingrm   r   r   r   rF   _typesr   	_urlparser	   _utilsr
   __all__r   Mappingr   r   r   r5   r3   <module>r      sO    "  5 5  #  *-
 R
 R
j]
&..c* ]
r5   