VYWã@s˜ddlmZddlmZddlmZddddd d d gZdZGdd„dedeƒƒZdd„Z dd„Z dd„Z dS)é)Úabsolute_import)Ú namedtupleé)ÚLocationParseErrorÚschemeÚauthÚhostÚportÚpathÚqueryÚfragmentÚhttpÚhttpsNc s—eZdZdZfZddddddd‡fdd†Zedd„ƒZedd„ƒZed d „ƒZ ed d „ƒZ d d„Z ‡S)ÚUrlzÌ Datastructure 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. Nc s{|r |jdƒ r d|}|r2|jƒ}|rP|tkrP|jƒ}tt|ƒj||||||||ƒS)Nú/)Ú startswithÚlowerÚNORMALIZABLE_SCHEMESÚsuperrÚ__new__)Úclsrrrr r r r )Ú __class__©úF/tmp/pip-build-04bmskau/requests/requests/packages/urllib3/util/url.pyrs   !z Url.__new__cCs|jS)z@For backwards-compatibility with urlparse. We're nice like that.)r)ÚselfrrrÚhostname!sz Url.hostnamecCs3|jp d}|jdk r/|d|j7}|S)z)Absolute path including the query string.rNú?)r r )rÚurirrrÚ request_uri&szUrl.request_uricCs$|jrd|j|jfS|jS)z(Network location including host and portz%s:%d)r r)rrrrÚnetloc0s z Url.netlocc CsÙ|\}}}}}}}d}|dk r;||d7}|dk rU||d7}|dk rk||7}|dk r‹|dt|ƒ7}|dk r¡||7}|dk r»|d|7}|dk rÕ|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ú#)Ústr) rrrrr r r r Úurlrrrr%7s"         zUrl.urlcCs|jS)N)r%)rrrrÚ__str___sz Url.__str__) Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú __slots__rÚpropertyrrrr%r&rr)rrrs   (rcCs©d}d}xP|D]H}|j|ƒ}|dkr7q|dksO||kr|}|}qW|dksw|dkr„|ddfS|d|…||dd…|fS)aÒ 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. Nrr é)Úfind)ÚsÚdelimsÚmin_idxÚ min_delimÚdÚidxrrrÚ split_firstcs    r5c Cs |s tƒSd}d}d}d}d}d}d}d|kr[|jddƒ\}}t|dddgƒ\}}} | rŒ| |}d|kr°|jddƒ\}}|rè|dd krè|jd dƒ\}}|d 7}d |krs|jd dƒ\} }|s| }|rj|jƒs6t|ƒ‚yt|ƒ}Wqptk rft|ƒ‚YqpXq†d}n| r†|r†|}|s¨t|||||||ƒSd|krÌ|jddƒ\}}d|krð|jddƒ\}}t|||||||ƒ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. 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', ...) Nz://r-rrr#r!rú[ú]r")rÚsplitr5ÚrsplitÚisdigitrÚintÚ ValueError) r%rrrr r r r Úpath_ÚdelimÚ_hostrrrÚ parse_url„sP !           r@cCs(t|ƒ}|jpd|j|jfS)z4 Deprecated. Use :func:`parse_url` instead. r )r@rrr )r%ÚprrrÚget_hostás rB)zhttpzhttpsN) Ú __future__rÚ collectionsrÚ exceptionsrÚ url_attrsrrr5r@rBrrrrÚsU ! ]