ó ½z]c@sldZddlZddlmZddlmZddlmZddlmZdefd „ƒYZ dS( s;Module containing the implementation of the URIMixin class.iÿÿÿÿNi(t exceptions(tmisc(t normalizers(t validatorstURIMixincBséeZdZejZd„Zd„Zed„ƒZed„ƒZ ed„ƒZ d„Z d„Z e d„Ze d „Ze d „Ze d „Ze d „Zd „Ze d„Zd„Zejejejejejd„ZRS(s0Mixin with all shared methods for URIs and IRIs.cCsÃ|js"idd6dd6dd6S|jƒ}|dkr[tj|jj|jƒƒ‚n|jƒ}|jdƒ}|r¿t j j |ƒr¿t j |ƒ r¿tj|jj|jƒƒ‚n|S(sÌReturn a dictionary with the ``userinfo``, ``host``, and ``port``. If the authority is not valid, it will raise a :class:`~rfc3986.exceptions.InvalidAuthority` Exception. :returns: ``{'userinfo': 'username:password', 'host': 'www.example.com', 'port': '80'}`` :rtype: dict :raises rfc3986.exceptions.InvalidAuthority: If the authority is not ``None`` and can not be parsed. tuserinfothosttportN(t authoritytNonet_match_subauthoritytexctInvalidAuthoritytencodetencodingt groupdicttgetRt IPv4_MATCHERtmatchRtvalid_ipv4_host_address(tselfRtmatchesR((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pytauthority_infos   ! !cCstjj|jƒS(N(RtSUBAUTHORITY_MATCHERRR(R((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyR 5scCs0y|jƒ}Wntjk r'dSX|dS(s+If present, a string representing the host.RN(RR R R (RR((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyR8s cCs0y|jƒ}Wntjk r'dSX|dS(s2If present, the port extracted from the authority.RN(RR R R (RR((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyRAs cCs0y|jƒ}Wntjk r'dSX|dS(s6If present, the userinfo extracted from the authority.RN(RR R R (RR((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyRJs cCsttjj|jƒƒƒS(séDetermine if this URI Reference is an absolute URI. See http://tools.ietf.org/html/rfc3986#section-4.3 for explanation. :returns: ``True`` if it is an absolute URI, ``False`` otherwise. :rtype: bool (tboolRtABSOLUTE_URI_MATCHERRtunsplit(R((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyt is_absoluteSscKs¢tjdtƒ|j|jdtƒf|j|jdtƒf|j|jdtƒf|j|jdtƒf|j |jdtƒfg}t d„|DƒƒS(sbDetermine if the URI is valid. .. deprecated:: 1.1.0 Use the :class:`~rfc3986.validators.Validator` object instead. :param bool require_scheme: Set to ``True`` if you wish to require the presence of the scheme component. :param bool require_authority: Set to ``True`` if you wish to require the presence of the authority component. :param bool require_path: Set to ``True`` if you wish to require the presence of the path component. :param bool require_query: Set to ``True`` if you wish to require the presence of the query component. :param bool require_fragment: Set to ``True`` if you wish to require the presence of the fragment component. :returns: ``True`` if the URI is valid. ``False`` otherwise. :rtype: bool sXPlease use rfc3986.validators.Validator instead. This method will be eventually removed.trequire_schemetrequire_authorityt require_patht require_querytrequire_fragmentcss!|]\}}||ƒVqdS(N((t.0tvtr((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pys {s( twarningstwarntDeprecationWarningtscheme_is_validRtFalsetauthority_is_validt path_is_validtquery_is_validtfragment_is_validtall(RtkwargsR((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pytis_valid]s cCsUtjdtƒy|jƒWntjk r5tSXtj|j d|j d|ƒS(sDetermine if the authority component is valid. .. deprecated:: 1.1.0 Use the :class:`~rfc3986.validators.Validator` object instead. :param bool require: Set to ``True`` to require the presence of this component. :returns: ``True`` if the authority is valid. ``False`` otherwise. :rtype: bool sXPlease use rfc3986.validators.Validator instead. This method will be eventually removed.Rtrequire( R$R%R&RR R R(RR)RR(RR0((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyR)}s   cCs#tjdtƒtj|j|ƒS(s`Determine if the scheme component is valid. .. deprecated:: 1.1.0 Use the :class:`~rfc3986.validators.Validator` object instead. :param str require: Set to ``True`` to require the presence of this component. :returns: ``True`` if the scheme is valid. ``False`` otherwise. :rtype: bool sXPlease use rfc3986.validators.Validator instead. This method will be eventually removed.(R$R%R&RR'tscheme(RR0((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyR'™s cCs#tjdtƒtj|j|ƒS(s\Determine if the path component is valid. .. deprecated:: 1.1.0 Use the :class:`~rfc3986.validators.Validator` object instead. :param str require: Set to ``True`` to require the presence of this component. :returns: ``True`` if the path is valid. ``False`` otherwise. :rtype: bool sXPlease use rfc3986.validators.Validator instead. This method will be eventually removed.(R$R%R&RR*tpath(RR0((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyR*ªs cCs#tjdtƒtj|j|ƒS(s^Determine if the query component is valid. .. deprecated:: 1.1.0 Use the :class:`~rfc3986.validators.Validator` object instead. :param str require: Set to ``True`` to require the presence of this component. :returns: ``True`` if the query is valid. ``False`` otherwise. :rtype: bool sXPlease use rfc3986.validators.Validator instead. This method will be eventually removed.(R$R%R&RR+tquery(RR0((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyR+»s cCs#tjdtƒtj|j|ƒS(sGDetermine if the fragment component is valid. .. deprecated:: 1.1.0 Use the Validator object instead. :param str require: Set to ``True`` to require the presence of this component. :returns: ``True`` if the fragment is valid. ``False`` otherwise. :rtype: bool sXPlease use rfc3986.validators.Validator instead. This method will be eventually removed.(R$R%R&RR,tfragment(RR0((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyR,Ìs cCs"t|jƒƒt|jƒƒkS(sCompare this URIReference to another URIReference. :param URIReference other_ref: (required), The reference with which we're comparing. :returns: ``True`` if the references are equal, ``False`` otherwise. :rtype: bool (ttuplet normalize(Rt other_ref((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pytnormalized_equalityÝsc CsÇt|tƒs't|ƒj|ƒ}n|jƒsEtj|ƒ‚n|jƒ}|}| r…|j|jkr…|j ddƒ}n|jdk rµ|j dt j |j ƒƒ}n|jdk rî|j d|jdt j |j ƒƒ}nÕ|j dkrQ|jdk r|j}n |j}|j d|jd|jd|j d|ƒ}nr|j jdƒrxt j |j ƒ}nt j tj||j ƒƒ}|j d|jd|jd|d|jƒ}|S(s¢Use an absolute URI Reference to resolve this relative reference. Assuming this is a relative reference that you would like to resolve, use the provided base URI to resolve it. See http://tools.ietf.org/html/rfc3986#section-5 for more information. :param base_uri: Either a string or URIReference. It must be an absolute URI or it will raise an exception. :returns: A new URIReference which is the result of resolving this reference using ``base_uri``. :rtype: :class:`URIReference` :raises rfc3986.exceptions.ResolutionError: If the ``base_uri`` is not an absolute URI. R1R2RR3t/N(t isinstanceRttypet from_stringRR tResolutionErrorR6R1t copy_withR Rtnormalize_pathR2RR3t startswithRt merge_paths(Rtbase_uritstrictt resolvingttargetR3R2((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyt resolve_withçsD                cCsÃg}|jr(|j|jdgƒn|jrJ|jd|jgƒn|jrf|j|jƒn|jdk rŽ|jd|jgƒn|jdk r¶|jd|jgƒndj|ƒS(s…Create a URI string from the components. :returns: The URI Reference reconstituted as a string. :rtype: str t:s//t?t#tN( R1textendRR2tappendR3R R4tjoin(Rt result_list((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyR-s   c Cs„i|d6|d6|d6|d6|d6}x9t|jƒƒD]%\}}|tjkr<||=q<q<W|j|} |j| _| S(sCreate a copy of this reference with the new components. :param str scheme: (optional) The scheme to use for the new reference. :param str authority: (optional) The authority to use for the new reference. :param str path: (optional) The path to use for the new reference. :param str query: (optional) The query to use for the new reference. :param str fragment: (optional) The fragment to use for the new reference. :returns: New URIReference with provided components. :rtype: URIReference R1RR2R3R4(tlisttitemsRt UseExistingt_replaceR( RR1RR2R3R4t attributestkeytvalueturi((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyR>As  (t__name__t __module__t__doc__R5t__hash__RR tpropertyRRRRR/R(R)R'R*R+R,R8RFRRRQR>(((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyR s(  &         F   ( RYR$RJRR RRRtobjectR(((s@/tmp/pip-build-kBFYxq/urllib3/urllib3/packages/rfc3986/_mixin.pyts