
    }Wh3                     ^    d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ  G d d	e          Z	dS )
z;Module containing the implementation of the URIMixin class.    N   )
exceptions)misc)normalizers)
validatorsc                       e Zd ZdZej        Zd Zd Zed             Z	ed             Z
ed             Zd Zd Zdd
ZddZddZddZddZd ZddZd Zej        ej        ej        ej        ej        fdZdS )URIMixinz0Mixin with all shared methods for URIs and IRIs.c                    | j         sddddS |                                 }|1t          j        | j                             | j                            |                                }|                    d          }|rdt          j	        
                    |          rEt          j        |          s1t          j        | j                             | j                            |S )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       T/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/rfc3986/_mixin.pyauthority_infozURIMixin.authority_info   s     ~ 	B $dDAAA((**=
 &t~'<'<T]'K'KLLL //##{{6"" 	M!''--	M 6t<<	M &t~'<'<T]'K'KLLL    c                 J    t           j                            | j                  S N)r   SUBAUTHORITY_MATCHERr   r   r   s    r   r   zURIMixin._match_subauthority8   s    (..t~>>>r   c                 j    	 |                                  }n# t          j        $ r Y dS w xY w|d         S )z+If present, a string representing the host.Nr   r   r   r   r   r   s     r   r   zURIMixin.host;   J    	++--II# 	 	 	44	      **c                 j    	 |                                  }n# t          j        $ r Y dS w xY w|d         S )z2If present, the port extracted from the authority.Nr   r#   r$   s     r   r   zURIMixin.portD   r%   r&   c                 j    	 |                                  }n# t          j        $ r Y dS w xY w|d         S )z6If present, the userinfo extracted from the authority.Nr   r#   r$   s     r   r   zURIMixin.userinfoM   sJ    	++--II# 	 	 	44	$$r&   c                 ~    t          t          j                            |                                                     S )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_absolutezURIMixin.is_absoluteV   s+     D-33DLLNNCCDDDr   c           	         t          j        dt                     | j        |                    dd          f| j        |                    dd          f| j        |                    dd          f| j        |                    dd          f| j        |                    dd          fg}t          d |D                       S )	ab  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   2   K   | ]\  }} ||          V  d S r    ).0vrs      r   	<genexpr>z$URIMixin.is_valid.<locals>.<genexpr>   s.      //DAq11Q44//////r   )
warningswarnDeprecationWarningscheme_is_validr   authority_is_validpath_is_validquery_is_validfragment_is_validall)r   kwargsr   s      r   is_validzURIMixin.is_valid`   s    ( 	6	
 	
 	
 !6::.>#F#FG$fjj1De&L&LMNE!B!BC &**_e"D"DE#VZZ0BE%J%JK

 //J//////r   Fc                     t          j        dt                     	 |                                  n# t          j        $ r Y dS w xY wt          j        | j        | j	        |          S )a  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
        r/   F)r   require)
r;   r<   r=   r   r   r   r   r?   r   r   r   rG   s     r   r?   zURIMixin.authority_is_valid   s     	6	
 	
 	

	!!!!# 	 	 	55	 ,N
 
 
 	
s   1 AAc                 j    t          j        dt                     t          j        | j        |          S )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
        r/   )r;   r<   r=   r   r>   schemerH   s     r   r>   zURIMixin.scheme_is_valid   s7     	6	
 	
 	

 )$+w???r   c                 j    t          j        dt                     t          j        | j        |          S )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
        r/   )r;   r<   r=   r   r@   pathrH   s     r   r@   zURIMixin.path_is_valid   s7     	6	
 	
 	

 '	7;;;r   c                 j    t          j        dt                     t          j        | j        |          S )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
        r/   )r;   r<   r=   r   rA   queryrH   s     r   rA   zURIMixin.query_is_valid   s7     	6	
 	
 	

 (W===r   c                 j    t          j        dt                     t          j        | j        |          S )aG  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
        r/   )r;   r<   r=   r   rB   fragmentrH   s     r   rB   zURIMixin.fragment_is_valid   s7     	6	
 	
 	

 +DM7CCCr   c                     t          |                                           t          |                                          k    S )a  Compare 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_equalityzURIMixin.normalized_equality   s5     T^^%%&&%	0C0C0E0E*F*FFFr   c                    t          |t                    s"t          |                               |          }|                                st          j        |          |                                }| }|s&|j        |j        k    r|	                    d          }|j        /|	                    t          j        |j                            }n	|j        4|	                    |j        t          j        |j                            }n|j        ?|j        |j        }n|j        }|	                    |j        |j        |j        |          }n|j                            d          rt          j        |j                  }n,t          j        t!          j        ||j                            }|	                    |j        |j        ||j                  }|S )a  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)rJ   )rL   )rJ   rL   )rJ   r   rL   rN   /)
isinstancer	   typefrom_stringr-   r   ResolutionErrorrS   rJ   	copy_withr   normalize_pathrL   r   rN   
startswithr   merge_paths)r   base_uristrict	resolvingtargetrN   rL   s          r   resolve_withzURIMixin.resolve_with   s     (H-- 	8Dzz--h77H##%% 	0%h/// %%'' 	 	9)*ho==!++4+88I '(( /	?? )  FF ".",,#?$3INCC -  
 >) 2 ) (&00'"*"4%]#	 1  FF !~0055 *9).II*9 ,Xy~FF    '00'"*"4!'o	 1  F r   c                    g }| j         r|                    | j         dg           | j        r|                    d| j        g           | j        r|                    | j                   | j        |                    d| j        g           | j        |                    d| j        g           d                    |          S )zCreate a URI string from the components.

        :returns: The URI Reference reconstituted as a string.
        :rtype: str
        :z//N?# )rJ   extendr   rL   appendrN   rP   join)r   result_lists     r   r,   zURIMixin.unsplit<  s     ; 	3S1222> 	7dn56669 	*ty))):!TZ0111=$T]3444ww{###r   c                     |||||d}t          |                                          D ]\  }}|t          j        u r||=  | j        di |}	| j        |	_        |	S )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
        )rJ   r   rL   rN   rP   r6   )listitemsr   UseExisting_replacer   )
r   rJ   r   rL   rN   rP   
attributeskeyvalueuris
             r   r\   zURIMixin.copy_withP  s    4 " 
 

 z//1122 	$ 	$JC(((sOdm))j))}
r   N)F)__name__
__module____qualname____doc__rR   __hash__r   r   propertyr   r   r   r-   rE   r?   r>   r@   rA   rB   rU   rd   r,   r   rq   r\   r6   r   r   r	   r	   
   s       ::~H' ' 'R? ? ? ! ! X! ! ! X! % % X%E E E 0  0  0D
 
 
 
<@ @ @ @&< < < <&> > > >&D D D D&G G GD D D DL$ $ $, "!% % % % % %r   r	   )
rz   r;   ri   r   r   r   r   r   objectr	   r6   r   r   <module>r~      s    A A                         k k k k kv k k k k kr   