
    	a?                     ~    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  G d d	 ed	ej                        e      Z
y
)z?Module containing the implementation of the URIReference class.    )
namedtuple   )compat)misc)normalizers)URIMixinc                   `     e Zd ZdZdZ	 d fd	Zej                  Zd Zd Z	e
dd       Z xZS )URIReferencea  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 address parsed from the authority.

    .. attribute:: port

        The port parsed from the authority.
     c                 V    t         |   | |xs d|xs d|xs d||      }||_        |S )zCreate a new URIReference.N)super__new__encoding)	clsscheme	authoritypathqueryfragmentr   ref	__class__s	           -/usr/lib/python3/dist-packages/rfc3986/uri.pyr   zURIReference.__new__T   s@     goNdLD
  
    c                 P   |}t        |t              r	t        | }n&t        |t              s	 t        j                  |      }t        |       t        |      k(  }|xs | j                  |      S # t        $ r. t	        dj                  t        |      j                              w xY w)z"Compare this reference to another.z(Unable to compare URIReference() to {}())	
isinstancetupler
   from_string	TypeErrorformattype__name__normalized_equality)selfother	other_refnaive_equalitys       r   __eq__zURIReference.__eq__e   s    	eU#$e,IE<0(44U;	 ti(88D!9!9)!DD  >EEU,, s   A. .7B%c           	         t        t        j                  | j                  xs d      t        j                  | j
                  | j                  | j                  f      t        j                  | j                  xs d      t        j                  | j                        t        j                  | j                        | j                        S )a  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
         )r
   r   normalize_schemer   normalize_authorityuserinfohostportnormalize_pathr   normalize_queryr   normalize_fragmentr   r   )r#   s    r   	normalizezURIReference.normalizex   s     (():;++		4995 &&tyyB7''

3**4==9MM	
 		
r   c           
      8   t        j                  ||      }t        j                  j	                  |      j                         } | |d   |d   t        j                  |d   |      t        j                  |d   |      t        j                  |d   |      |      S )a	  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   to_strr   URI_MATCHERmatch	groupdictr   encode_component)r   
uri_stringr   	split_uris       r   r   zURIReference.from_string   s     ]]:x8
$$**:6@@B	hk"((6):HE((7);XF((:)>I
 	
r   )zutf-8)r!   
__module____qualname____doc__slotsr   r   __hash__r'   r2   classmethodr   __classcell__)r   s   @r   r
   r
      sF    7r E AH ~~HE&
, 
 
r   r
   N)r=   collectionsr   r)   r   r   r   _mixinr   URI_COMPONENTSr
   r   r   r   <module>rE      s6    E #    H
:nd.A.ABH H
r   