o
    8D©i?  ã                   @   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 G dd	„ d	ed	ej	ƒeƒZ
d
S )z?Module containing the implementation of the URIReference class.é    )Ú
namedtupleé   )Úcompat)Úmisc)Únormalizers)ÚURIMixinc                       sL   e Zd ZdZdZ	d‡ fdd„	ZejZdd„ Zdd	„ Z	e
dd
d„ƒZ‡  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.
    © úutf-8c                    s,   t ƒ  | |pd|p
d|pd||¡}||_|S )zCreate a new URIReference.N)ÚsuperÚ__new__Úencoding)ÚclsÚschemeÚ	authorityÚpathÚqueryÚfragmentr   Úref©Ú	__class__r	   úD/var/www/Datamplify/venv/lib/python3.10/site-packages/rfc3986/uri.pyr   T   s   úzURIReference.__new__c                 C   sr   |}t |tƒrt|Ž }nt |tƒs*zt |¡}W n ty)   td t|ƒj¡ƒ‚w t| ƒt|ƒk}|p8|  |¡S )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_equalityr	   r	   r   Ú__eq__e   s   


ÿÿÿzURIReference.__eq__c                 C   sN   t t | jpd¡t | j| j| jf¡t | j	pd¡t 
| j¡t | 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    r	   r	   r   Ú	normalizex   s   ÿ

øzURIReference.normalizec              	   C   sZ   t  ||¡}tj |¡ ¡ }| |d |d t |d |¡t |d |¡t |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_urir	   r	   r   r   Ž   s   úzURIReference.from_string)r
   )r   Ú
__module__Ú__qualname__Ú__doc__Úslotsr   r   Ú__hash__r$   r.   Úclassmethodr   Ú__classcell__r	   r	   r   r   r      s    9ÿr   N)r8   Úcollectionsr   r%   r   r   r   Ú_mixinr   ÚURI_COMPONENTSr   r	   r	   r	   r   Ú<module>   s    