ó
ä™L]c           @   s   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d e d e j	 ƒ e f d	 „  ƒ  YZ
 d
 S(   s?   Module containing the implementation of the URIReference class.iÿÿÿÿ(   t
   namedtuplei   (   t   compat(   t   misc(   t   normalizers(   t   URIMixint   URIReferencec           B   sM   e  Z d  Z d Z d d „ Z e j Z d „  Z d „  Z e	 d d „ ƒ Z
 RS(   sİ  Immutable object representing a parsed URI Reference.

    .. note::

        This class is not intended to be directly instantiated by the user.

    This object exposes attributes for the following components of a
    URI:

    - scheme
    - authority
    - path
    - query
    - fragment

    .. attribute:: scheme

        The scheme that was parsed for the URI Reference. For example,
        ``http``, ``https``, ``smtp``, ``imap``, etc.

    .. attribute:: authority

        Component of the URI that contains the user information, host,
        and port sub-components. For example,
        ``google.com``, ``127.0.0.1:5000``, ``username@[::1]``,
        ``username:password@example.com:443``, etc.

    .. attribute:: path

        The path that was parsed for the given URI Reference. For example,
        ``/``, ``/index.php``, etc.

    .. attribute:: query

        The query component for a given URI Reference. For example, ``a=b``,
        ``a=b%20c``, ``a=b+c``, ``a=b,c=d,e=%20f``, etc.

    .. attribute:: fragment

        The fragment component of a URI. For example, ``section-3.1``.

    This class also provides extra attributes for easier access to information
    like the subcomponents of the authority component.

    .. attribute:: userinfo

        The user information parsed from the authority.

    .. attribute:: host

        The hostname, IPv4, or IPv6 adddres parsed from the authority.

    .. attribute:: port

        The port parsed from the authority.
    s   utf-8c         C   sF   t  t |  ƒ j |  | p d | p$ d | p- d | | ƒ } | | _ | S(   s   Create a new URIReference.N(   t   superR   t   __new__t   Nonet   encoding(   t   clst   schemet	   authorityt   patht   queryt   fragmentR	   t   ref(    (    sE   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/uri.pyR   U   s    					c         C   s¦   | } t  | t ƒ r$ t | Œ  } nW t  | t ƒ s{ y t j | ƒ } Wq{ t k
 rw t d j t | ƒ j ƒ ƒ ‚ q{ Xn  t |  ƒ t | ƒ k } | p¥ |  j | ƒ S(   s"   Compare this reference to another.s)   Unable to compare URIReference() to {0}()(	   t
   isinstancet   tupleR   t   from_stringt	   TypeErrort   formatt   typet   __name__t   normalized_equality(   t   selft   othert	   other_reft   naive_equality(    (    sE   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/uri.pyt   __eq__d   s    c         C   ss   t  t j |  j p d ƒ t j |  j |  j |  j f ƒ t j |  j	 pH d ƒ t j
 |  j ƒ t j |  j ƒ |  j ƒ S(   s  Normalize this reference as described in Section 6.2.2.

        This is not an in-place normalization. Instead this creates a new
        URIReference.

        :returns: A new reference object with normalized components.
        :rtype: URIReference
        t    (   R   R   t   normalize_schemeR   t   normalize_authorityt   userinfot   hostt   portt   normalize_pathR   t   normalize_queryR   t   normalize_fragmentR   R	   (   R   (    (    sE   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/uri.pyt	   normalizeu   s    c         C   s{   t  j | | ƒ } t j j | ƒ j ƒ  } |  | d | d t j | d | ƒ t j | d | ƒ t j | d | ƒ | ƒ S(   s	  Parse a URI reference from the given unicode URI string.

        :param str uri_string: Unicode URI to be parsed into a reference.
        :param str encoding: The encoding of the string provided
        :returns: :class:`URIReference` or subclass thereof
        R   R   R   R   R   (   R   t   to_strR   t   URI_MATCHERt   matcht	   groupdictR   t   encode_component(   R
   t
   uri_stringR	   t	   split_uri(    (    sE   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/uri.pyR   ˆ   s    (    (   R   t
   __module__t   __doc__t   slotsR   R   t   __hash__R   R'   t   classmethodR   (    (    (    sE   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/uri.pyR      s   8			N(   R0   t   collectionsR    R   R   R   R   t   _mixinR   t   URI_COMPONENTSR   (    (    (    sE   /tmp/pip-build-sZz8gW/pip/pip/_vendor/urllib3/packages/rfc3986/uri.pyt   <module>   s   