๓
abc @@ sบ d d l m Z d d l m Z d d l Z d d l m Z d d d d d
d d g Z d Z e j
d Z d d l m
Z
d e d e f d YZ d Z d Z d Z d S( i ( t absolute_import( t
namedtupleNi ( t LocationParseErrort schemet autht hostt portt patht queryt fragmentt httpt httpss [ - ]( t quotet Urlc B@ sw e Z d Z d Z d d d d d d d d Z e d Z e d Z e d Z e d Z
d Z RS( sฬ
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.
c C@ s | r# | j d r# d | } n | r8 | j } n | rY | t k rY | j } n t t | j | | | | | | | | S( Nt /( t
startswitht lowert NORMALIZABLE_SCHEMESt superR
t __new__( t clsR R R R R R R ( ( s@ /usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/url.pyR s
!c C@ s | j S( s@ For backwards-compatibility with urlparse. We're nice like that.( R ( t self( ( s@ /usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/url.pyt hostname$ s c C@ s6 | j p d } | j d k r2 | d | j 7} n | S( s) Absolute path including the query string.R t ?N( R R t None( R t uri( ( s@ /usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/url.pyt request_uri) s c C@ s$ | j r d | j | j f S| j S( s( Network location including host and ports %s:%d( R R ( R ( ( s@ /usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/url.pyt netloc3 s c C@ s๎ | \ } } } } } } } d } | d k r> | | d 7} n | d k r[ | | d 7} n | d k rt | | 7} n | d k r | d t | 7} n | d k rฐ | | 7} n | d k rอ | d | 7} n | d k r๊ | d | 7} n | S( s
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'
t s ://t @t :R t #N( R t str( R R R R R R R R t url( ( s@ /usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/url.pyR! : s"
c C@ s | j S( N( R! ( R ( ( s@ /usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/url.pyt __str__b s ( N( t __name__t
__module__t __doc__t __slots__R R t propertyR R R R! R" ( ( ( s@ /usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/url.pyR
s
(c C@ sฃ d } d } xV | D]N } | j | } | d k r: q n | d k sR | | k r | } | } q q W| d k s} | d k r | d d f S| | | | d | f S( sา
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.
i R i N( R t find( t st delimst min_idxt min_delimt dt idx( ( s@ /usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/url.pyt split_firstf s
c C@ s; | s
t St j d | } d } d } d } d } d } d } d } d | k rs | j d d \ } } n t | d d d g \ } } } | rง | | } n d | k rฮ | j d d \ } } n | r | d d k r | j d
d \ } } | d
7} n d | k r| j d d \ }
} | s<|
} n | r| j s]t | n y t | } Wqt
k
rt | qXqฏd } n | rฏ| rฏ| } n | sัt | | | | | | | Sd | k r๘| j d d \ } } n d | k r| j d d \ } } n t | | | | | | | S(
s:
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', ...)
c S@ s t | j S( N( R t group( t match( ( s@ /usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/url.pyt