ó
ä™L]c           @   sP   d  Z  d d l m Z d d l m Z d d l m Z d e f d „  ƒ  YZ d S(   s6   Module containing the logic for the URIBuilder object.i   (   t   compat(   t   normalizers(   t   urit
   URIBuilderc           B   s†   e  Z d  Z d d d d d d d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z RS(   s  Object to aid in building up a URI Reference from parts.

    .. note::

        This object should be instantiated by the user, but it's recommended
        that it is not provided with arguments. Instead, use the available
        method to populate the fields.

    c         C   sC   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d S(   s€  Initialize our URI builder.

        :param str scheme:
            (optional)
        :param str userinfo:
            (optional)
        :param str host:
            (optional)
        :param int port:
            (optional)
        :param str path:
            (optional)
        :param str query:
            (optional)
        :param str fragment:
            (optional)
        N(   t   schemet   userinfot   hostt   portt   patht   queryt   fragment(   t   selfR   R   R   R   R   R	   R
   (    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt   __init__    s    						c         C   s   d } | j  d |  ƒ S(   s0   Provide a convenient view of our builder object.s‰   URIBuilder(scheme={b.scheme}, userinfo={b.userinfo}, host={b.host}, port={b.port}, path={b.path}, query={b.query}, fragment={b.fragment})t   b(   t   format(   R   t	   formatstr(    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt   __repr__;   s    c         C   sR   t  j | ƒ } t d | d |  j d |  j d |  j d |  j d |  j d |  j ƒ S(   s“  Add a scheme to our builder object.

        After normalizing, this will generate a new URIBuilder instance with
        the specified scheme and all other attributes the same.

        .. code-block:: python

            >>> URIBuilder().add_scheme('HTTPS')
            URIBuilder(scheme='https', userinfo=None, host=None, port=None,
                    path=None, query=None, fragment=None)

        R   R   R   R   R   R	   R
   (	   R   t   normalize_schemeR   R   R   R   R   R	   R
   (   R   R   (    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt
   add_schemeB   s    					c         C   s—   | d
 k r t d ƒ ‚ n  t j | ƒ } | d
 k	 rT d j | t j | ƒ ƒ } n  t d |  j d | d |  j d |  j	 d |  j
 d |  j d	 |  j ƒ S(   së  Add credentials as the userinfo portion of the URI.

        .. code-block:: python

            >>> URIBuilder().add_credentials('root', 's3crete')
            URIBuilder(scheme=None, userinfo='root:s3crete', host=None,
                    port=None, path=None, query=None, fragment=None)

            >>> URIBuilder().add_credentials('root', None)
            URIBuilder(scheme=None, userinfo='root', host=None,
                    port=None, path=None, query=None, fragment=None)
        s   Username cannot be Nones   {}:{}R   R   R   R   R   R	   R
   N(   t   Nonet
   ValueErrorR   t   normalize_usernameR   t   normalize_passwordR   R   R   R   R   R	   R
   (   R   t   usernamet   passwordR   (    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt   add_credentialsZ   s    					c         C   sL   t  d |  j d |  j d t j | ƒ d |  j d |  j d |  j d |  j ƒ S(   s  Add hostname to the URI.

        .. code-block:: python

            >>> URIBuilder().add_host('google.com')
            URIBuilder(scheme=None, userinfo=None, host='google.com',
                    port=None, path=None, query=None, fragment=None)

        R   R   R   R   R   R	   R
   (	   R   R   R   R   t   normalize_hostR   R   R	   R
   (   R   R   (    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt   add_host{   s    
					c         C   s    t  | ƒ } | d k  r0 t d j | ƒ ƒ ‚ n  | d k rT t d j | ƒ ƒ ‚ n  t d |  j d |  j d |  j d d	 j | ƒ d
 |  j d |  j d |  j	 ƒ S(   sœ  Add port to the URI.

        .. code-block:: python

            >>> URIBuilder().add_port(80)
            URIBuilder(scheme=None, userinfo=None, host=None, port='80',
                    path=None, query=None, fragment=None)

            >>> URIBuilder().add_port(443)
            URIBuilder(scheme=None, userinfo=None, host=None, port='443',
                    path=None, query=None, fragment=None)

        i    s5   ports are not allowed to be negative. You provided {}iÿÿ  s>   ports are not allowed to be larger than 65535. You provided {}R   R   R   R   s   {}R   R	   R
   (
   t   intR   R   R   R   R   R   R   R	   R
   (   R   R   t   port_int(    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt   add_port�   s"    					c         C   sm   | j  d ƒ s! d j | ƒ } n  t d |  j d |  j d |  j d |  j d t j | ƒ d |  j	 d	 |  j
 ƒ S(
   sÛ  Add a path to the URI.

        .. code-block:: python

            >>> URIBuilder().add_path('sigmavirus24/rfc3985')
            URIBuilder(scheme=None, userinfo=None, host=None, port=None,
                    path='/sigmavirus24/rfc3986', query=None, fragment=None)

            >>> URIBuilder().add_path('/checkout.php')
            URIBuilder(scheme=None, userinfo=None, host=None, port=None,
                    path='/checkout.php', query=None, fragment=None)

        t   /s   /{}R   R   R   R   R   R	   R
   (   t
   startswithR   R   R   R   R   R   R   t   normalize_pathR	   R
   (   R   R   (    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt   add_path¶   s    					c         C   s[   t  j t j | ƒ ƒ } t d |  j d |  j d |  j d |  j d |  j	 d | d |  j
 ƒ S(   sæ  Generate and add a query a dictionary or list of tuples.

        .. code-block:: python

            >>> URIBuilder().add_query_from({'a': 'b c'})
            URIBuilder(scheme=None, userinfo=None, host=None, port=None,
                    path=None, query='a=b+c', fragment=None)

            >>> URIBuilder().add_query_from([('a', 'b c')])
            URIBuilder(scheme=None, userinfo=None, host=None, port=None,
                    path=None, query='a=b+c', fragment=None)

        R   R   R   R   R   R	   R
   (   R   t   normalize_queryR    t	   urlencodeR   R   R   R   R   R   R
   (   R   t   query_itemsR	   (    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt   add_query_fromÑ   s    					c         C   sL   t  d |  j d |  j d |  j d |  j d |  j d t j | ƒ d |  j ƒ S(   s  Add a pre-formated query string to the URI.

        .. code-block:: python

            >>> URIBuilder().add_query('a=b&c=d')
            URIBuilder(scheme=None, userinfo=None, host=None, port=None,
                    path=None, query='a=b&c=d', fragment=None)

        R   R   R   R   R   R	   R
   (	   R   R   R   R   R   R   R   R#   R
   (   R   R	   (    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt	   add_queryë   s    
					c         C   sL   t  d |  j d |  j d |  j d |  j d |  j d |  j d t j | ƒ ƒ S(   s  Add a fragment to the URI.

        .. code-block:: python

            >>> URIBuilder().add_fragment('section-2.6.1')
            URIBuilder(scheme=None, userinfo=None, host=None, port=None,
                    path=None, query=None, fragment='section-2.6.1')

        R   R   R   R   R   R	   R
   (	   R   R   R   R   R   R   R	   R   t   normalize_fragment(   R   R
   (    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt   add_fragmentÿ   s    
						c         C   s@   t  j |  j t j |  j |  j |  j f ƒ |  j |  j	 |  j
 ƒ S(   s>  Create a URIReference from our builder.

        .. code-block:: python

            >>> URIBuilder().add_scheme('https').add_host('github.com'
            ...     ).add_path('sigmavirus24/rfc3986').finalize().unsplit()
            'https://github.com/sigmavirus24/rfc3986'

            >>> URIBuilder().add_scheme('https').add_host('github.com'
            ...     ).add_path('sigmavirus24/rfc3986').add_credentials(
            ...     'sigmavirus24', 'not-re@l').finalize().unsplit()
            'https://sigmavirus24:not-re%40l@github.com/sigmavirus24/rfc3986'

        (   R   t   URIReferenceR   R   t   normalize_authorityR   R   R   R   R	   R
   (   R   (    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt   finalize  s    N(   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R   R"   R&   R'   R)   R,   (    (    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyR      s   				!		'				N(   R/   t    R    R   R   t   objectR   (    (    (    sI   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/builder.pyt   <module>   s   