CYhm;ddlmZddlZddlZddlmZddlmZdZejdZ ejd Z ejd ejejzZd Zd Zd j#eeZeedZgdZdZddj-eDcgc]}|ez c}zdzZdezdzZdezdzezdzZdZejdZejdezdzZejdezdzZejdezdzZejdeddzdzZejdezdzZ d ededed!Z!eje!ejejzZ"e#d"Z$e#d#Z%e$e%zd$hzZ&e&d%d&hzZ'e'd'hzxZ(Z)Gd(d)ejTd)d*ejVe,fd+ejVe,fd,ejVe,fd-ejVe-fd.ejVe,fd/ejVe,fd0ejVe,fgZ.ej^ d;d1Z0ej^ dd4Z1ej^d?d5Z2ej^d@d6Z2dAd7Z2dBd8Z3dCd9Z4dDd:Z5ycc}w)E) annotationsN)LocationParseError)to_str)httphttpsNz%[a-fA-F0-9]{2}z^(?:[a-zA-Z][a-zA-Z0-9+-]*:|/)zS^(?:([a-zA-Z][a-zA-Z0-9+.-]*):)?(?://([^\\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$z(?:[0-9]{1,3}\.){3}[0-9]{1,3}z[0-9A-Fa-f]{1,4}z(?:{hex}:{hex}|{ipv4}))hexipv4)r ls32) z(?:%(hex)s:){6}%(ls32)sz::(?:%(hex)s:){5}%(ls32)sz%(?:%(hex)s)?::(?:%(hex)s:){4}%(ls32)sz2(?:(?:%(hex)s:)?%(hex)s)?::(?:%(hex)s:){3}%(ls32)sz6(?:(?:%(hex)s:){0,2}%(hex)s)?::(?:%(hex)s:){2}%(ls32)sz/(?:(?:%(hex)s:){0,3}%(hex)s)?::%(hex)s:%(ls32)sz'(?:(?:%(hex)s:){0,4}%(hex)s)?::%(ls32)sz&(?:(?:%(hex)s:){0,5}%(hex)s)?::%(hex)sz(?:(?:%(hex)s:){0,6}%(hex)s)?::zCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._\-~z(?:|)z (?:%25|%)(?:[z]|%[a-fA-F0-9]{2})+z\[z)?\]z!(?:[^\[\]%:/?#]|%[a-fA-F0-9]{2})*z!^(/[^?#]*)(?:\?([^#]*))?(?:#.*)?$^$(z)\]$z^(z)(?::0*?(|0|[1-9][0-9]{0,4}))?$zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~z !$&'()*+,;=:@/?ceZdZdZ d d fd Zed dZed dZed dZed dZ ed dZ d dZ xZ S) Urlz Data structure for representing an HTTP URL. Used as a return value for :func:`parse_url`. Both the scheme and host are normalized as they are both case-insensitive according to RFC 3986. c |r|jdsd|z}||j}t| ||||||||S)Nr) startswithlowersuper__new__) clsschemeauthhostportpathqueryfragment __class__s 2/usr/lib/python3/dist-packages/urllib3/util/url.pyrz Url.__new__dsJ ,:D  \\^FwsFD$dE8TTc|jS)z@For backwards-compatibility with urlparse. We're nice like that.)r!selfs r'hostnamez Url.hostnametsyyr(cb|jxsd}|j|d|jzz }|S)z)Absolute path including the query string.rr)r#r$)r+uris r' request_urizUrl.request_uriys4ii3 :: ! 3# #C r(cL|j}|j}|||S|d|S)z Authority component as defined in RFC 3986 3.2. This includes userinfo (auth), host and port. i.e. userinfo@host:port r)r netloc)r+userinfor1s r' authorityz Url.authoritys699 >X-MZq) )r(c|jy|jr|jd|jS|jS)z Network location including host and port. If you need the equivalent of urllib.parse's ``netloc``, use the ``authority`` property instead. Nr)r!r"r*s r'r1z Url.netlocs; 99  99ii[$))- -yyr(c|\}}}}}}}d}|||dzz }|||dzz }|||z }||dt|zz }|||z }||d|zz }||d|zz }|S)a2 Convert self into a url This function should more or less round-trip with :func:`.parse_url`. The returned url may not be exactly the same as the url inputted to :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls with a blank port will have : removed). Example: .. code-block:: python import urllib3 U = urllib3.util.parse_url("https://google.com/mail/") print(U.url) # "https://google.com/mail/" print( urllib3.util.Url("https", "username:password", "host.com", 80, "/path", "query", "fragment" ).url ) # "https://username:password@host.com:80/path?query#fragment" z://rrr#)str) r+rr r!r"r#r$r%urls r'r9zUrl.urls6;?7dD$x   6E> !C   4#: C   4KC   3T? "C   4KC   3; C   3> !C r(c|jSN)r9r*s r'__str__z Url.__str__s xxr()NNNNNNN)r str | Noner r=r!r=r"z int | Noner#r=r$r=r%r=)returnr=)r>r8) __name__ __module__ __qualname____doc__rpropertyr,r/r3r1r9r< __classcell__)r&s@r'rrPs" #UUU U  U  UUU  * *  --^r(rrr r!r"r#r$r%cyr; component allowed_charss r'_encode_invalid_charsrJr(cyr;rFrGs r'rJrJrKr(c ||St|}tjd|\}}|jdd}||j dk(}t }t dt|D]}|||dz}t|}|r|dk(s|dkr|j|vr||z }:|jdt|d djjd jz|jS) zfPercent-encodes a URI component without reapplying onto an already percent-encoded component. Nc@|jdjS)Nr)groupupper)matchs r'z'_encode_invalid_chars..sekk!n**,r(zutf-8 surrogatepass%rrr)r _PERCENT_REsubnencodecount bytearrayrangelenorddecodeextendr zfillrP) rHrIpercent_encodings uri_bytesis_percent_encodedencoded_componentibytebyte_ords r'rJrJs y!I $/#3#3,i$ I   /:I*iood.CC!  1c)n % WQU#t9 44< sNt{{} =  %    Xqr):)A)A)C)I)I!)L)R)R)T!UV W  # # %%r(cP|jd}g}|D]2}|dk(r |dk7r|j| |s#|j4|jdr|r|dr|j dd|j dr|jddj |S)Nr.z..rr6)z/.z/..)splitappendpoprinsertendswithjoin)r#segmentsoutputsegments r'_remove_path_dot_segmentsrsszz#H F  c>  d? MM' " JJL  sVvay a }}]# b 88F r(cyr;rFr!rs r'_normalize_hostrv%r(cyr;rFrus r'rvrv*rwr(c |r|tvrtj|}|rtj |}|rg|j d\}}|||}|j dr |dk7r|dd}n|dd}t|t}|d|jd|||dS|jStj|sAtdj|jdDcgc] }t|c}dS|Scc}w)Nrz%25%.riascii)_NORMALIZABLE_SCHEMES_IPV6_ADDRZ_RErQ _ZONE_ID_REsearchspanrrJ_UNRESERVED_CHARSr_IPV4_RErrorj _idna_encode)r!ris_ipv6rQstartendzone_idlabels r'rvrv/s * *$**40G$**40!&AJE3"5oG))%0W5E")!"+")!"+3G=NOG"6El00231WId34j\JJ::<'^^D)II 3Pu|E2PQ KQs)D c(|js( ddl} |j |j ddS|j j dS#t$r tddwxYw#|j $rtd|ddwxYw)Nrz-Unable to parse URL without the 'idna' moduleT)strict std3_ruleszName 'z' is not a valid IDNA labelr})isasciiidna ImportErrorrrXr IDNAError)namers r'rrLs <<>    ;;tzz|DT;J J ::<  w '' $?  ~~ $9:  sA!A1A.1 Bctj|}|st|d|j\}}t |t }|t |t }|d|zz }|S)zPercent-encodes a request target so that there are no invalid characters Pre-condition for this function is that 'target' must start with '/'. If that is the case then _TARGET_RE will always produce a match. z is not a valid request URIr) _TARGET_RErQrgroupsrJ _PATH_CHARS _QUERY_CHARS)targetrQr#r$encoded_targets r'_encode_targetr_sk   V $E  F:-H!IJJ,,.KD%*4=N %e\:#+% r(c T|s tS|}tj|sd|z} tj |j \}}}}}|duxs|j tv}|r|j }|r]|jd\}} } |xsd}tj | j \} } |r|rt|t}| dk(r d} nd\}} } | -t| } d| cxkrdkst|t|d} t| |} |r|rt|}t|t }|r|rt|t"}|r|rt|t$}|s ||d}nd}t||| | |||S#t&t(f$r}t||d}~wwxYw) a Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. This parser is RFC 3986 and RFC 6874 compliant. The parser logic and helper functions are based heavily on work done in the ``rfc3986`` module. :param str url: URL to parse into a :class:`.Url` namedtuple. Partly backwards-compatible with :mod:`urllib.parse`. Example: .. code-block:: python import urllib3 print( urllib3.util.parse_url('http://google.com/mail/')) # Url(scheme='http', host='google.com', port=None, path='/mail/', ...) print( urllib3.util.parse_url('google.com:80')) # Url(scheme=None, host='google.com', port=80, path=None, ...) print( urllib3.util.parse_url('/foo?bar')) # Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...) z//Nrr6)NNNri)rr r!r"r#r$r%)r _SCHEME_REr_URI_RErQrrr~ rpartition _HOST_PORT_RErJ_USERINFO_CHARSintrrvrsrr_FRAGMENT_CHARS ValueErrorAttributeError)r9 source_urlrr3r#r$r% normalize_urir _ host_portr!r"port_intes r' parse_urlrqs8 u J   S !Sj$43:==3E3L3L3N0 4$Q&,,.>@JD$ ,T?Crz/ D$  4yH*U*(--+(--HtV, T,T2D({;D U)%>E X,XGH    4DD        '4 ,!34sEFF' F""F')rHr8rItyping.Container[str]r>r8)rHNonerIrr>r)rHr=rIrr>r=)r#r8r>r8)r!rrr=r>r)r!r8rr=r>r8)r!r=rr=r>r=)rr8r>bytes)rr8r>r8)r9r8r>r)6 __future__rretyping exceptionsrutilrr~compilerVrUNICODEDOTALLr _IPV4_PAT_HEX_PATformat _LS32_PAT_subs _variations_UNRESERVED_PATro _IPV6_PAT _ZONE_ID_PAT_IPV6_ADDRZ_PAT _REG_NAME_PATrr_IPV6_REr_BRACELESS_IPV6_ADDRZ_REr_HOST_PORT_PATrsetr_SUB_DELIM_CHARSrrrr NamedTupleOptionalr8rroverloadrJrsrvrrr)xs0r'rsx" +0bjj+, RZZ9 : "** JJ   -  $ + +y + I ), *Y CHH=Aa%i=> > D 03HH )#f,|;gE4 RZZ< = 2::cIo+ , 2::cIo+ ,C/1C78%2::cOAb,A&AC&GHbjj|+g56    >2:: +AB H}%#&66#>c * !,u!44 BF vs+ , V__S) * V__S) * V__S) * V__S) * fooc* + - .  BJ#8 $9  !&!&*?!&!&H<:(&$f{ >s J;