
    01i3                     V    S r SSKrSSKJr  SSKJr  SSKJr  SSKJr   " S S	\5      r	g)
z;Module containing the implementation of the URIMixin class.    N   )
exceptions)misc)normalizers)
validatorsc                   8   \ rS rSrSr\R                  rS rS r\	S 5       r
\	S 5       r\	S 5       rS rS	 rSS
 jrSS jrSS jrSS jrSS jrS rSS jrS r\R0                  \R0                  \R0                  \R0                  \R0                  4S jrSrg)URIMixin
   z0Mixin with all shared methods for URIs and IRIs.c                    U R                   (       d  SSSS.$ U R                  5       nUc9  [        R                  " U R                   R	                  U R
                  5      5      eUR                  5       nUR                  S5      nU(       ax  [        R                  R                  U5      (       aT  [        R                  " U5      (       d9  [        R                  " U R                   R	                  U R
                  5      5      eU$ )a  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.
N)userinfohostportr   )	authority_match_subauthorityexcInvalidAuthorityencodeencoding	groupdictgetr   IPv4_MATCHERmatchr   valid_ipv4_host_address)selfr   matchesr   s       H/home/james-whalen/.local/lib/python3.13/site-packages/rfc3986/_mixin.pyauthority_infoURIMixin.authority_info   s     ~~ $dDAA((*=
 &&t~~'<'<T]]'KLL //#{{6" !!''--66t<< &&t~~'<'<T]]'KLL    c                 T    [         R                  R                  U R                  5      $ N)r   SUBAUTHORITY_MATCHERr   r   r   s    r   r   URIMixin._match_subauthority8   s    ((..t~~>>r   c                 b     U R                  5       nUS   $ ! [        R                   a     gf = f)z+If present, a string representing the host.Nr   r   r   r   r   r   s     r   r   URIMixin.host;   <    	++-I    ## 		    ..c                 b     U R                  5       nUS   $ ! [        R                   a     gf = f)z2If present, the port extracted from the authority.Nr   r&   r'   s     r   r   URIMixin.portD   r)   r*   c                 b     U R                  5       nUS   $ ! [        R                   a     gf = f)z6If present, the userinfo extracted from the authority.Nr   r&   r'   s     r   r   URIMixin.userinfoM   s<    	++-I $$ ## 		r*   c                 n    [        [        R                  R                  U R	                  5       5      5      $ )zDetermine 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
)boolr   ABSOLUTE_URI_MATCHERr   unsplitr#   s    r   is_absoluteURIMixin.is_absoluteV   s&     D--33DLLNCDDr   c           	         [         R                  " S[        5        U R                  UR	                  SS5      4U R
                  UR	                  SS5      4U R                  UR	                  SS5      4U R                  UR	                  SS5      4U R                  UR	                  SS5      4/n[        S U 5       5      $ )	a  Determine 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
XPlease use rfc3986.validators.Validator instead. This method will be eventually removed.require_schemeFrequire_authorityrequire_pathrequire_queryrequire_fragmentc              3   6   #    U  H  u  pU" U5      v   M     g 7fr!    ).0vrs      r   	<genexpr>$URIMixin.is_valid.<locals>.<genexpr>   s     /JDA1Q44Js   )
warningswarnDeprecationWarningscheme_is_validr   authority_is_validpath_is_validquery_is_validfragment_is_validall)r   kwargsr   s      r   is_validURIMixin.is_valid`   s    ( 	6	
 !!6::.>#FG$$fjj1De&LMNE!BC  &**_e"DE##VZZ0BE%JK

 /J///r   c                     [         R                  " S[        5         U R                  5         [        R                  " U R                  U R                  US9$ ! [        R
                   a     gf = f)a7  Determine 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
r6   F)r   require)
rC   rD   rE   r   r   r   r   rG   r   r   r   rP   s     r   rG   URIMixin.authority_is_valid   si     	6	

	! ,,NN
 	
 ## 		s   A A.-A.c                 z    [         R                  " S[        5        [        R                  " U R
                  U5      $ )a(  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
r6   )rC   rD   rE   r   rF   schemerQ   s     r   rF   URIMixin.scheme_is_valid   s1     	6	

 ))$++w??r   c                 z    [         R                  " S[        5        [        R                  " U R
                  U5      $ )a$  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
r6   )rC   rD   rE   r   rH   pathrQ   s     r   rH   URIMixin.path_is_valid   s1     	6	

 ''		7;;r   c                 z    [         R                  " S[        5        [        R                  " U R
                  U5      $ )a&  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
r6   )rC   rD   rE   r   rI   queryrQ   s     r   rI   URIMixin.query_is_valid   s1     	6	

 ((W==r   c                 z    [         R                  " S[        5        [        R                  " U R
                  U5      $ )a  Determine 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
r6   )rC   rD   rE   r   rJ   fragmentrQ   s     r   rJ   URIMixin.fragment_is_valid   s1     	6	

 ++DMM7CCr   c                 h    [        U R                  5       5      [        UR                  5       5      :H  $ )zCompare 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
)tuple	normalize)r   	other_refs     r   normalized_equalityURIMixin.normalized_equality   s)     T^^%&%	0C0C0E*FFFr   c                 X   [        U[        5      (       d  [        U 5      R                  U5      nUR	                  5       (       d  [
        R                  " U5      eUR                  5       nU nU(       d)  UR                  UR                  :X  a  UR                  SS9nUR                  b/  UR                  [        R                  " UR                  5      S9nU$ UR                  b:  UR                  UR                  [        R                  " UR                  5      S9nU$ UR                  cX  UR                  b  UR                  nOUR                  nUR                  UR                  UR                  UR                  US9nU$ UR                  R                  S5      (       a!  [        R                  " UR                  5      nO4[        R                  " [         R"                  " XR                  5      5      nUR                  UR                  UR                  UUR                  S9nU$ )aJ  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.
N)rT   )rW   )rT   rW   )rT   r   rW   rZ   /)
isinstancer	   typefrom_stringr3   r   ResolutionErrorra   rT   	copy_withr   normalize_pathrW   r   rZ   
startswithr   merge_paths)r   base_uristrict	resolvingtargetrZ   rW   s          r   resolve_withURIMixin.resolve_with   s     (H--Dz--h7H##%%%%h// %%' 	)**hoo=!++4+8I '(( //	? ) FD = "".",,#??$33INNC - : 1 >>) 2 ) (&00'"*"4"4%]]#	 1 F&  !~~0055*99)..I*99 ,,X~~F  '00'"*"4"4!'oo	 1 F r   c                    / nU R                   (       a  UR                  U R                   S/5        U R                  (       a  UR                  SU R                  /5        U R                  (       a  UR	                  U R                  5        U R
                  b  UR                  SU R
                  /5        U R                  b  UR                  SU R                  /5        SR                  U5      $ )zmCreate a URI string from the components.

:returns: The URI Reference reconstituted as a string.
:rtype: str
:z//?# )rT   extendr   rW   appendrZ   r]   join)r   result_lists     r   r2   URIMixin.unsplit<  s     ;;S12>>dnn5699tyy)::!TZZ01==$T]]34ww{##r   c                     UUUUUS.n[        UR                  5       5       H  u  pxU[        R                  L d  M  Xg	 M     U R                  " S0 UD6n	U R
                  U	l        U	$ )a  Create 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
)rT   r   rW   rZ   r]   r=   )listitemsr   UseExisting_replacer   )
r   rT   r   rW   rZ   r]   
attributeskeyvalueuris
             r   rk   URIMixin.copy_withP  sl    4 " 

 z//12JC(((O 3 mm)j)}}
r   r=   N)F)__name__
__module____qualname____firstlineno____doc__r`   __hash__r   r   propertyr   r   r   r3   rM   rG   rF   rH   rI   rJ   rc   rs   r2   r   r   rk   __static_attributes__r=   r   r   r	   r	   
   s    :~~H'R? ! ! ! ! % %E 0D
<@&<&>&D&GDL$, ""!!%r   r	   )
r   rC   ry   r   r   r   r   r   objectr	   r=   r   r   <module>r      s%    A     kv kr   