Viewing File: /opt/alt/python35/lib/python3.5/site-packages/urllib3/util/__pycache__/url.cpython-35.opt-1.pyc



R/oV÷ã@s’ddlmZddlmZddlmZddddd	d
dgZGdd
„d
ed
eƒƒZdd„Zdd„Z	dd„Z
dS)é)Úabsolute_import)Ú
namedtupleé)ÚLocationParseErrorÚschemeÚauthÚhostÚportÚpathÚqueryÚfragmentc
s—eZdZdZfZddddddd‡fdd†Zedd„ƒZedd„ƒZed	d
„ƒZ	edd„ƒZ
d
d„Z‡S)ÚUrlzg
    Datastructure for representing an HTTP URL. Used as a return value for
    :func:`parse_url`.
    Nc	sK|r |jdƒr d|}tt|ƒj||||||||ƒS)Nú/)Ú
startswithÚsuperr
Ú__new__)Úclsrrrr	r
rr)Ú	__class__©ú/url.pyrs
!zUrl.__new__cCs|jS)z@For backwards-compatibility with urlparse. We're nice like that.)r)ÚselfrrrÚhostnameszUrl.hostnamecCs3|jpd}|jdk	r/|d|j7}|S)z)Absolute path including the query string.rNú?)r
r)rZurirrrÚrequest_uriszUrl.request_uricCs$|jrd|j|jfS|jS)z(Network location including host and portz%s:%d)r	r)rrrrÚnetloc's	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
rrÚurlrrrr .s"

zUrl.urlcCs|jS)N)r )rrrrÚ__str__VszUrl.__str__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚslotsrÚpropertyrrrr r!rr)rrr

s
(r
cCs©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)ÚsZdelimsZmin_idxZ	min_delimÚdÚidxrrrÚsplit_firstZs


r-cCsç|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|krN|jddƒ\}
}|s|
}|rE|jƒs6t|ƒ‚t|ƒ}qad}n|ra|ra|}|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(rrrrrú[ú]r)r
Úsplitr-ÚrsplitÚisdigitrÚint)r rrrr	r
rrZpath_ÚdelimZ_hostrrrÚ	parse_url{sJ!

	
r5cCs(t|ƒ}|jpd|j|jfS)z5
    Deprecated. Use :func:`.parse_url` instead.
    Zhttp)r5rrr	)r ÚprrrÚget_hostÔsr7N)Z
__future__rÚcollectionsrÚ
exceptionsrZ	url_attrsr
r-r5r7rrrrÚ<module>sP!Y
Back to Directory File Manager