î
)Ú X÷  ã               @   s’   d  d l  m Z d  d l m Z d d l m Z d d d d d	 d
 d g Z Gd d „  d e d e ƒ ƒ Z d d „  Z d d „  Z	 d d „  Z
 d S)é    )Úabsolute_import)Ú
namedtupleé   )ÚLocationParseErrorÚschemeÚauthÚhostÚportÚpathÚqueryÚfragmentc            
       s—   e  Z d  Z d Z f  Z d d d d d d d ‡  f d d † Z e d d „  ƒ Z e d d „  ƒ Z e d	 d
 „  ƒ Z	 e d d „  ƒ Z
 d d „  Z ‡  S)ÚUrlzg
    Datastructure for representing an HTTP URL. Used as a return value for
    :func:`parse_url`.
    Nc          	      sN   | r# | j  d ƒ r# d | } n  t t |  ƒ j |  | | | | | | | ƒ S)Nú/)Ú
startswithÚsuperr   Ú__new__)Úclsr   r   r   r	   r
   r   r   )Ú	__class__© úR/home/ubuntu/projects/ifolica/build/requests/requests/packages/urllib3/util/url.pyr      s    !zUrl.__new__c             C   s   |  j  S)z@For backwards-compatibility with urlparse. We're nice like that.)r   )Úselfr   r   r   Úhostname   s    zUrl.hostnamec             C   s6   |  j  p d } |  j d k	 r2 | d |  j 7} n  | S)z)Absolute path including the query string.r   Nú?)r
   r   )r   Úurir   r   r   Úrequest_uri   s    zUrl.request_uric             C   s$   |  j  r d |  j |  j  f S|  j S)z(Network location including host and portz%s:%d)r	   r   )r   r   r   r   Únetloc'   s    	z
Url.netlocc       	      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)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)	r   r   r   r   r	   r
   r   r   Úurlr   r   r   r!   .   s"    zUrl.urlc             C   s   |  j  S)N)r!   )r   r   r   r   Ú__str__V   s    zUrl.__str__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úslotsr   Úpropertyr   r   r   r!   r"   r   r   )r   r   r   
   s   
(r   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 | … |  | d d … | f S)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.
    Nr   r   é   )Úfind)ÚsÚdelimsÚmin_idxÚ	min_delimÚdÚidxr   r   r   Úsplit_firstZ   s    r1   c             C   s  |  s t  ƒ  Sd } d } d } d } d } d } d } d |  k r^ |  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  | rW| j ƒ  sHt |  ƒ ‚ n  t | ƒ } qvd } n | rv|  rv|  } n  | s˜t  | | | | | | | ƒ Sd | k r¿| j d d ƒ \ } } n  d | k ræ| j d d ƒ \ } } n  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)   r   r   r   r   r   ú[ú]r   )r   Úsplitr1   ÚrsplitÚisdigitr   Úint)r!   r   r   r   r	   r
   r   r   Úpath_ÚdelimÚ_hostr   r   r   Ú	parse_url{   sJ    !			r;   c             C   s(   t  |  ƒ } | j p d | j | j f S)z5
    Deprecated. Use :func:`.parse_url` instead.
    Úhttp)r;   r   r   r	   )r!   Úpr   r   r   Úget_hostÔ   s    r>   N)Ú
__future__r   Úcollectionsr   Ú
exceptionsr   Z	url_attrsr   r1   r;   r>   r   r   r   r   Ú<module>   s   P!Y