a *Na6@sddlmZddlZddlmZddlmZddlmZgdZ dZ e d Z e d Z e d ejejBZd Zd ZdjeedZeedZgdZdZddddeDdZdedZdededZdZe dZe dedZe dedZe dedZ e dedd dZ!e d!ed"Z"d#eeefZ#e e#ejejBZ$e%d$Z&e%d%Z'e&e'Bd&hBZ(e(d'd(hBZ)e)d)hBZ*Z+Gd*d+d+ed+e Z,d,d-Z-d=d/d0Z.d1d2Z/d3d4Z0d5d6Z1d7d8Z2d9d:Z3d;d<Z4dS)>)absolute_importN) namedtuple)LocationParseError)sixschemeauthhostportpathqueryfragment)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}))hexZipv4)rls32) 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)?::zDABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._!\-~z(?:|cCsg|] }|tqS)_subs.0xrrk/private/var/folders/js/6pj4vh5d4zd0k6bxv74qrbhr0000gr/T/pip-target-22xwyzbs/lib/python/urllib3/util/url.py 6r)z (?:%25|%)(?:[z]|%[a-fA-F0-9]{2})+z\[z)?\]z!(?:[^\[\]%:/?#]|%[a-fA-F0-9]{2})*z!^(/[^?#]*)(?:\?([^#]*))?(?:#.*)?$^$(z)\]$z^(%s|%s|%s)(?::([0-9]{0,5}))?$zBABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~z !$&'()*+,;=:@/?cs^eZdZdZdZdfdd ZeddZedd Zed d Z ed d Z ddZ Z 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. rNc sD|r|dsd|}|dur&|}tt|||||||||S)Nr#) startswithlowersuperr%__new__)clsrr r r r r r __class__rrr)[s  z Url.__new__cCs|jS)z@For backwards-compatibility with urlparse. We're nice like that.)r selfrrrhostnamemsz Url.hostnamecCs&|jpd}|jdur"|d|j7}|S)z)Absolute path including the query string.r#Nr$)r r )r.urirrr request_urirs  zUrl.request_uricCs|jrd|j|jfS|jS)z(Network location including host and portz%s:%d)r r r-rrrnetloc|sz Url.netlocc Cs|\}}}}}}}d}|dur*||d7}|dur>||d7}|durN||7}|durf|dt|7}|durv||7}|dur|d|7}|dur|d|7}|S)a 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: :: >>> U = parse_url('http://google.com/mail/') >>> U.url 'http://google.com/mail/' >>> Url('http', 'username:password', 'host.com', 80, ... '/path', 'query', 'fragment').url 'http://username:password@host.com:80/path?query#fragment' Nz://r"r!r$#)str) r.rr r r r r rurlrrrr6s"    zUrl.urlcCs|jSN)r6r-rrr__str__sz Url.__str__)NNNNNNN) __name__ __module__ __qualname____doc__ __slots__r)propertyr/r1r2r6r8 __classcell__rrr+rr%Rs&    'r%cCsvd}d}|D]0}||}|dkr$q |dus4||kr |}|}q |dusN|dkrX|ddfS|d|||dd|fS)a .. deprecated:: 1.25 Given a string and an iterable of delimiters, split on the first found delimiter. Return two split parts and the matched delimiter. If not found, then the first part is the full input string. Example:: >>> split_first('foo/bar?baz', '?/=') ('foo', 'bar?baz', '/') >>> split_first('foo/bar?baz', '123') ('foo/bar?baz', '', None) Scales linearly with number of delims. Not ideal for large number of delims. Nrr3)find)sdelimsmin_idx min_delimdidxrrr split_firsts  rHutf-8c Cs|dur |St|}tdd|\}}|dd}||dk}t}tdt|D]n}|||d}t |} |r|dks| d kr| |vr||7}qX| dt | d d d qX| |S) zfPercent-encodes a URI component without reapplying onto an already percent-encoded component. NcSs|dS)Nr)groupupper)matchrrrrz'_encode_invalid_chars..rI surrogatepass%rr@r)r ensure_text PERCENT_REsubnencodecount bytearrayrangelenorddecodeextendrzfillrK) component allowed_charsencodingpercent_encodings uri_bytesis_percent_encodedencoded_componentibytebyte_ordrrr_encode_invalid_charss*    *rgcCs|d}g}|D]0}|dkr"qq|dkr6||q|r|q|drf|rZ|drf|dd|drz|dd|S)Nr#.z..rr3)z/.z/..)splitappendpopr&insertendswithjoin)r segmentsoutputsegmentrrr_remove_path_dot_segmentss      rrcCs|rt|tjrt|}|tvrt|}|rt|}|r| d\}}|||}| drx|dkrx|dd}n |dd}dt |t }|d| |||dS| Sn*t|stddd|dDS|S) Nr@z%25%.cSsg|] }t|qSr) _idna_encode)rlabelrrrr)rz#_normalize_host..rh) isinstancer binary_type ensure_strNORMALIZABLE_SCHEMES IPV6_ADDRZ_RErL ZONE_ID_REsearchspanr&rgUNRESERVED_CHARSr'IPV4_RErnri)r ris_ipv6rLstartendzone_idrrr_normalize_hosts*         rcCs|rtdd|Drz ddl}Wn"tyDttddYn0z|j|dddWS|jyttd|dYn0|dS) NcSsg|]}t|dkqS)rP)rYrrrrr/rz _idna_encode..rz-Unable to parse URL without the 'idna' moduleT)strict std3_rulesz#Name '%s' is not a valid IDNA labelascii) anyidna ImportErrorr raise_fromrrTr' IDNAError)namerrrrrv.s    rvcCs>t|\}}t|t}t|t}|dur:|d|7}|S)zHPercent-encodes a request target so that there are no invalid charactersNr$) TARGET_RErLgroupsrg PATH_CHARS QUERY_CHARS)targetr r rrr_encode_target@s    rc s|s tS|}t|s d|}zt|\}}}}}|dupN|tv}|r\|}|r|d\}} } |pvd}t | \} } |r|rt |t }| dkrd} n d\}} } | durt | } d| krdksnt |t| |} |r |r t|}t |t}|r |r t |t}|r6|r6t |t}Wn(ttfy`tt |dYS0|s|dus||durd}nd}t|tjrtjntjfdd } t| || || | | | || || |d S) 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 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:`urlparse`. Example:: >>> parse_url('http://google.com/mail/') Url(scheme='http', host='google.com', port=None, path='/mail/', ...) >>> parse_url('google.com:80') Url(scheme=None, host='google.com', port=80, path=None, ...) >>> parse_url('/foo?bar') Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...) z//Nr"r3)NNNrics|dur |S|Sr7r)r ensure_funcrr ensure_typeszparse_url..ensure_typer)r% SCHEME_REr~URI_RErLrr'r{ rpartition _HOST_PORT_RErgUSERINFO_CHARSintrrrrrrFRAGMENT_CHARS ValueErrorAttributeErrorrrrx text_typerQrz)r6 source_urlr authorityr r r normalize_urir _ host_portr r rrrr parse_urlJsd          rcCst|}|jpd|j|jfS)z4 Deprecated. Use :func:`parse_url` instead. r)rrr/r )r6prrrget_hostsr)rI)5 __future__rre collectionsr exceptionsrpackagesr url_attrsr{compilerRrUNICODEDOTALLrIPV4_PATHEX_PATformatLS32_PATr _variationsUNRESERVED_PATrnIPV6_PAT ZONE_ID_PATIPV6_ADDRZ_PAT REG_NAME_PATrrIPV6_REr|BRACELESS_IPV6_ADDRZ_REr}Z_HOST_PORT_PATrsetrSUB_DELIM_CHARSrrrrr%rHrgrrrrvrrrrrrrsd            ]# " a