3 §˜‚]kã@s^dZddlmZddlmZddlmZddlmZddlmZGdd „d ed ej ƒeƒZ d S) z?Module containing the implementation of the URIReference class.é)Ú namedtupleé)Úcompat)Úmisc)Ú normalizers)ÚURIMixincsJeZdZdZfZd ‡fdd„ ZejZdd„Zdd„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 adddres parsed from the authority. .. attribute:: port The port parsed from the authority. úutf-8cs0tt|ƒj||pd|pd|pd||ƒ}||_|S)zCreate a new URIReference.N)ÚsuperrÚ__new__Úencoding)ÚclsÚschemeÚ authorityÚpathÚqueryÚfragmentr Úref)Ú __class__©ú?/tmp/pip-build-el9acr48/urllib3/urllib3/packages/rfc3986/uri.pyr Us zURIReference.__new__c Csx|}t|tƒrt|Ž}nBt|tƒsZytj|ƒ}Wn(tk rXtdjt|ƒjƒƒ‚YnXt|ƒt|ƒk}|pv|j|ƒS)z"Compare this reference to another.z)Unable to compare URIReference() to {0}()) Ú isinstanceÚtuplerÚ from_stringÚ TypeErrorÚformatÚtypeÚ__name__Znormalized_equality)ÚselfÚotherZ other_refZnaive_equalityrrrÚ__eq__ds   zURIReference.__eq__cCsNttj|jpdƒtj|j|j|jfƒtj|j p0dƒtj |j ƒtj |j ƒ|jƒS)aNormalize 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 Ú)rrZnormalize_schemerZnormalize_authorityÚuserinfoÚhostÚportÚnormalize_pathrZnormalize_queryrZnormalize_fragmentrr )rrrrÚ normalizeus   zURIReference.normalizecCsZtj||ƒ}tjj|ƒjƒ}||d|dtj|d|ƒtj|d|ƒtj|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 rrrrr)rZto_strrZ URI_MATCHERÚmatchÚ groupdictrZencode_component)r Z uri_stringr Z split_urirrrrˆs  zURIReference.from_string)r )r ) rÚ __module__Ú __qualname__Ú__doc__Úslotsr rÚ__hash__r r&Ú classmethodrÚ __classcell__rr)rrrs8 rN) r+Ú collectionsrr!rrrZ_mixinrZURI_COMPONENTSrrrrrÚs