B t…ƒ]kã@s^dZddlmZddlmZddlmZddlmZddlmZGdd „d ed ej ƒeƒZ d S) z?Module containing the implementation of the URIReference class.é)Ú namedtupleé)Úcompat)Úmisc)Ú normalizers)ÚURIMixincsJeZdZdZdZd ‡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|ƒ ||pd|pd|pd||¡}||_|S)zCreate a new URIReference.N)ÚsuperrÚ__new__Úencoding)ÚclsÚschemeÚ authorityÚpathÚqueryÚfragmentr Úref)Ú __class__r ú?/tmp/pip-build-0limmi1x/urllib3/urllib3/packages/rfc3986/uri.pyr Us zURIReference.__new__cCsx|}t|tƒrt|Ž}nBt|tƒsZyt |¡}Wn(tk rXtd t|ƒj¡ƒ‚YnXt|ƒt|ƒk}|pv| |¡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_equalityr r rÚ__eq__ds   zURIReference.__eq__cCsNtt |jpd¡t |j|j|jf¡t |j p0d¡t  |j ¡t  |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 )rr r rÚ normalizeus   zURIReference.normalizec CsZt ||¡}tj |¡ ¡}||d|dt |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 rrrrr)rZto_strrZ URI_MATCHERÚmatchÚ groupdictrZencode_component)rZ uri_stringr Z split_urir r rrˆs  zURIReference.from_string)r )r ) rÚ __module__Ú __qualname__Ú__doc__Úslotsr rÚ__hash__r r&Ú classmethodrÚ __classcell__r r )rrrs8 rN) r+Ú collectionsrr!rrrZ_mixinrZURI_COMPONENTSrr r r rÚs