§
    BP„jd*  ã                   óþ   — d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
  ej        e¦  «        ZdZdZdZ eeeeg¦  «        ZeZdZdZd	Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Z d„ Z!d„ Z"d„ Z#dS )z-Helper functions for commonly used utilities.é    N)ÚurllibÚWARNINGÚ	EXCEPTIONÚIGNOREzFile: {0}: Is a symbolic link.z{0}: Is a directoryz,Cannot access {0}: No such file or directoryc                 óâ   ‡ — ˆ fd„}t          ‰ t          j        ¦  «        r|S t          j        ‰ ¦  «        \  }}}} t          t          |¦  «        t          |¦  «        z
  ¦  «        ‰ ¦  «        S )aŽ  A decorator to declare that only the first N arguments my be positional.

    This decorator makes it easy to support Python 3 style keyword-only
    parameters. For example, in Python 3 it is possible to write::

        def fn(pos1, *, kwonly1=None, kwonly1=None):
            ...

    All named parameters after ``*`` must be a keyword::

        fn(10, 'kw1', 'kw2')  # Raises exception.
        fn(10, kwonly1='kw1')  # Ok.

    Example
    ^^^^^^^

    To define a function like above, do::

        @positional(1)
        def fn(pos1, kwonly1=None, kwonly2=None):
            ...

    If no default value is provided to a keyword argument, it becomes a
    required keyword argument::

        @positional(0)
        def fn(required_kw):
            ...

    This must be called with the keyword parameter::

        fn()  # Raises exception.
        fn(10)  # Raises exception.
        fn(required_kw=10)  # Ok.

    When defining instance or class methods always remember to account for
    ``self`` and ``cls``::

        class MyClass(object):

            @positional(2)
            def my_method(self, pos1, kwonly1=None):
                ...

            @classmethod
            @positional(2)
            def my_method(cls, pos1, kwonly1=None):
                ...

    The positional decorator behavior is controlled by
    ``_helpers.positional_parameters_enforcement``, which may be set to
    ``POSITIONAL_EXCEPTION``, ``POSITIONAL_WARNING`` or
    ``POSITIONAL_IGNORE`` to raise an exception, log a warning, or do
    nothing, respectively, if a declaration is violated.

    Args:
        max_positional_arguments: Maximum number of positional arguments. All
                                  parameters after the this index must be
                                  keyword only.

    Returns:
        A decorator that prevents using arguments after max_positional_args
        from being used as positional parameters.

    Raises:
        TypeError: if a key-word only argument is provided as a positional
                   parameter, but only if
                   _helpers.positional_parameters_enforcement is set to
                   POSITIONAL_EXCEPTION.
    c                 óJ   •‡ — t          j        ‰ ¦  «        ˆˆ fd„¦   «         }|S )Nc                  ó6  •— t          | ¦  «        ‰k    r~d}‰dk    rd}d                     ‰j        ‰t          | ¦  «        |¬¦  «        }t          t          k    rt          |¦  «        ‚t          t          k    rt                               |¦  «          ‰| i |¤ŽS )NÚ é   ÚszV{function}() takes at most {args_max} positional argument{plural} ({args_given} given))ÚfunctionÚargs_maxÚ
args_givenÚplural)	ÚlenÚformatÚ__name__Ú!positional_parameters_enforcementÚPOSITIONAL_EXCEPTIONÚ	TypeErrorÚPOSITIONAL_WARNINGÚloggerÚwarning)ÚargsÚkwargsÚplural_sÚmessageÚmax_positional_argsÚwrappeds       €€úZ/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/oauth2client/_helpers.pyÚpositional_wrapperzDpositional.<locals>.positional_decorator.<locals>.positional_wrapperu   s±   ø€ å�4‰yŒyÐ.Ò.Ð.Ø�Ø&¨!Ò+Ð+Ø"�HðCßCIÂ6Ø(/Ô(8Ø(;Ý*-¨d©)¬)Ø&.ð	 DJñ D0ô D0ð õ 5Õ8LÒLÐLÝ# GÑ,Ô,Ð,Ý6Õ:LÒLÐLÝ—N’N 7Ñ+Ô+Ð+Ø�7˜DÐ+ FÐ+Ð+Ð+ó    )Ú	functoolsÚwraps)r   r!   r   s   ` €r    Úpositional_decoratorz(positional.<locals>.positional_decoratort   s?   øø€ Ý	Œ˜Ñ	!Ô	!ð	,ð 	,ð 	,ð 	,ð 	,ñ 
"Ô	!ð	,ð  "Ð!r"   )Ú
isinstanceÚsixÚinteger_typesÚinspectÚ
getargspecÚ
positionalr   )r   r%   r   Ú_Údefaultss   `    r    r+   r+   ,   s€   ø€ ðP"ð "ð "ð "ð "õ( Ð%¥sÔ'8Ñ9Ô9ð JØ#Ð#å&Ô1Ð2EÑFÔFÑˆˆa��HØ4�z�#˜d™)œ)¥c¨(¡m¤mÑ3Ñ4Ô4Ð5HÑIÔIÐIr"   c                 ód   — t          | t          j        ¦  «        r| S d                     | ¦  «        S )a_  Converts scope value to a string.

    If scopes is a string then it is simply passed through. If scopes is an
    iterable then a string is returned that is all the individual scopes
    concatenated with spaces.

    Args:
        scopes: string or iterable of strings, the scopes.

    Returns:
        The scopes formatted as a single string.
    ú )r&   r'   Ústring_typesÚjoin©Úscopess    r    Úscopes_to_stringr4   �   s0   € õ �&�#Ô*Ñ+Ô+ð  Øˆà�xŠx˜ÑÔÐr"   c                 ól   — | sg S t          | t          j        ¦  «        r|                      d¦  «        S | S )a+  Converts stringifed scope value to a list.

    If scopes is a list then it is simply passed through. If scopes is an
    string then a list of each individual scope is returned.

    Args:
        scopes: a string or iterable of strings, the scopes.

    Returns:
        The scopes in a list.
    r/   )r&   r'   r0   Úsplitr2   s    r    Ústring_to_scopesr7   ¢   s=   € ð ð Øˆ	Ý	�F�CÔ,Ñ	-Ô	-ð Ø�|Š|˜CÑ Ô Ð àˆr"   c                 ó  — t           j                             | ¦  «        }i }t          j        |¦  «        D ]M\  }}t          |¦  «        dk    r*d|›dd                     |¦  «        ›�}t          |¦  «        ‚|d         ||<   ŒN|S )a  Parses unique key-value parameters from urlencoded content.

    Args:
        content: string, URL-encoded key-value pairs.

    Returns:
        dict, The key-value pairs from ``content``.

    Raises:
        ValueError: if one of the keys is repeated.
    r   z.URL-encoded content contains a repeated value:z -> z, r   )r   ÚparseÚparse_qsr'   Ú	iteritemsr   r1   Ú
ValueError)ÚcontentÚurlencoded_paramsÚparamsÚkeyÚvalueÚmsgs         r    Úparse_unique_urlencodedrC   ¶   s�   € õ œ×-Ò-¨gÑ6Ô6ÐØ€FÝ”mÐ$5Ñ6Ô6ð ð ‰
ˆˆUÝˆu‰:Œ:˜Š?ˆ?ˆ?à!$   d§i¢i°Ñ&6Ô&6Ð&6ð8ˆCå˜S‘/”/Ð!Ø˜A”hˆˆs‰ˆØ€Mr"   c                 ó:  — t           j                             | ¦  «        }t          |j        ¦  «        }|                     |¦  «         t           j                             |¦  «        }|                     |¬¦  «        }t           j                             |¦  «        S )a  Updates a URI with new query parameters.

    If a given key from ``params`` is repeated in the ``uri``, then
    the URI will be considered invalid and an error will occur.

    If the URI is valid, then each value from ``params`` will
    replace the corresponding value in the query parameters (if
    it exists).

    Args:
        uri: string, A valid URI, with potential existing query parameters.
        params: dict, A dictionary of query parameters.

    Returns:
        The same URI but with the new query parameters added.
    )Úquery)	r   r9   ÚurlparserC   rE   ÚupdateÚ	urlencodeÚ_replaceÚ
urlunparse)Úurir?   ÚpartsÚquery_paramsÚ	new_queryÚ	new_partss         r    Úupdate_query_paramsrP   Í   sz   € õ" ŒL×!Ò! #Ñ&Ô&€EÝ*¨5¬;Ñ7Ô7€LØ×Ò˜ÑÔÐÝ”×&Ò& |Ñ4Ô4€IØ—’ Y�Ñ/Ô/€IÝŒ<×"Ò" 9Ñ-Ô-Ð-r"   c                 ó.   — |€| S t          | ||i¦  «        S )a\  Adds a query parameter to a url.

    Replaces the current value if it already exists in the URL.

    Args:
        url: string, url to add the query parameter to.
        name: string, query parameter name.
        value: string, query parameter value.

    Returns:
        Updated query parameter. Does not update the url if value is None.
    )rP   )ÚurlÚnamerA   s      r    Ú_add_query_parameterrT   æ   s"   € ð €}Øˆ
å" 3¨¨u¨Ñ6Ô6Ð6r"   c                 ó¸  — t           j                             | ¦  «        r't          t                               | ¦  «        ¦  «        ‚t           j                             | ¦  «        r't          t                               | ¦  «        ¦  «        ‚t           j                             | ¦  «        s.t          j
        t                               | ¦  «        ¦  «         d S d S )N)ÚosÚpathÚislinkÚIOErrorÚ_SYM_LINK_MESSAGEr   ÚisdirÚ_IS_DIR_MESSAGEÚisfileÚwarningsÚwarnÚ_MISSING_FILE_MESSAGE)Úfilenames    r    Úvalidate_filerb   ù   s¬   € Ý	„w‡~‚~�hÑÔð >ÝÕ'×.Ò.¨xÑ8Ô8Ñ9Ô9Ð9Ý	Œ�Š�xÑ	 Ô	 ð >Ý•o×,Ò,¨XÑ6Ô6Ñ7Ô7Ð7ÝŒW�^Š^˜HÑ%Ô%ð >ÝŒÕ+×2Ò2°8Ñ<Ô<Ñ=Ô=Ð=Ð=Ð=ð>ð >r"   c                 óP   — |                       d¦  «        }|dk    r
| |d…         S dS )az  Identify and extract PEM keys.

    Determines whether the given key is in the format of PEM key, and extracts
    the relevant part of the key if it is.

    Args:
        raw_key_input: The contents of a private key file (either PEM or
                       PKCS12).

    Returns:
        string, The actual key if the contents are from a PEM file, or
        else None.
    s   -----BEGIN éÿÿÿÿN)Úfind)Úraw_key_inputÚoffsets     r    Ú_parse_pem_keyrh     s6   € ð ×Ò Ñ/Ô/€FØ�‚|€|Ø˜V˜W˜WÔ%Ð%ð €|r"   c                 ó.   — t          j        | d¬¦  «        S )N)ú,ú:)Ú
separators)ÚjsonÚdumps)Údatas    r    Ú_json_encoderp     s   € ÝŒ:�d zÐ2Ñ2Ô2Ð2r"   Úasciic                 óà   — t          | t          j        ¦  «        r|                      |¦  «        n| }t          |t          j        ¦  «        r|S t          d                     | ¦  «        ¦  «        ‚)a4  Converts a string value to bytes, if necessary.

    Unfortunately, ``six.b`` is insufficient for this task since in
    Python2 it does not modify ``unicode`` objects.

    Args:
        value: The string/bytes value to be converted.
        encoding: The encoding to use to convert unicode to bytes. Defaults
                  to "ascii", which will not allow any characters from ordinals
                  larger than 127. Other useful values are "latin-1", which
                  which will only allows byte ordinals (up to 255) and "utf-8",
                  which will encode any unicode that needs to be.

    Returns:
        The original value converted to bytes (if unicode) or as passed in
        if it started out as bytes.

    Raises:
        ValueError if the value could not be converted to bytes.
    z%{0!r} could not be converted to bytes)r&   r'   Ú	text_typeÚencodeÚbinary_typer<   r   )rA   ÚencodingÚresults      r    Ú	_to_bytesrx     sh   € õ, ˜E¥3¤=Ñ1Ô1ð=ˆe�lŠl˜8Ñ$Ô$Ð$Ø7<ð å�&�#œ/Ñ*Ô*ð PØˆåÐ@×GÒGÈÑNÔNÑOÔOÐOr"   c                 óà   — t          | t          j        ¦  «        r|                      d¦  «        n| }t          |t          j        ¦  «        r|S t          d                     | ¦  «        ¦  «        ‚)aE  Converts bytes to a string value, if necessary.

    Args:
        value: The string/bytes value to be converted.

    Returns:
        The original value converted to unicode (if bytes) or as passed in
        if it started out as unicode.

    Raises:
        ValueError if the value could not be converted to unicode.
    úutf-8z'{0!r} could not be converted to unicode)r&   r'   ru   Údecoders   r<   r   )rA   rw   s     r    Ú_from_bytesr|   6  sq   € õ ˜E¥3¤?Ñ3Ô3ð?ˆe�lŠl˜7Ñ#Ô#Ð#Ø9>ð å�&�#œ-Ñ(Ô(ð EØˆåØ5×<Ò<¸UÑCÔCñEô Eð 	Er"   c                 ór   — t          | d¬¦  «        } t          j        | ¦  «                             d¦  «        S )Nrz   )rv   ó   =)rx   Úbase64Úurlsafe_b64encodeÚrstrip)Ú	raw_bytess    r    Ú_urlsafe_b64encoderƒ   L  s3   € Ý˜)¨gÐ6Ñ6Ô6€IÝÔ# IÑ.Ô.×5Ò5°dÑ;Ô;Ð;r"   c                 ó~   — t          | ¦  «        } | ddt          | ¦  «        dz  z
  z  z   }t          j        |¦  «        S )Nr~   é   )rx   r   r   Úurlsafe_b64decode)Ú	b64stringÚpaddeds     r    Ú_urlsafe_b64decoder‰   Q  s?   € å˜)Ñ$Ô$€IØ˜ ¥S¨¡^¤^°aÑ%7Ñ!7Ñ8Ñ8€FÝÔ# FÑ+Ô+Ð+r"   )rq   )$Ú__doc__r   r#   r)   rm   ÚloggingrV   r^   r'   Ú	six.movesr   Ú	getLoggerr   r   r   r   ÚPOSITIONAL_IGNOREÚ	frozensetÚPOSITIONAL_SETr   rZ   r\   r`   r+   r4   r7   rC   rP   rT   rb   rh   rp   rx   r|   rƒ   r‰   © r"   r    ú<module>r’      s¨  ðð 4Ð 3à €€€Ø Ð Ð Ð Ø €€€Ø €€€Ø €€€Ø 	€	€	€	Ø €€€à 
€
€
€
Ø Ð Ð Ð Ð Ð ð 
ˆÔ	˜8Ñ	$Ô	$€àÐ Ø"Ð ØÐ Ø�Ð.Ð0DØ-ð/ñ 0ô 0€ð %7Ð !à4Ð Ø'€ØFÐ ð`Jð `Jð `JðF ð  ð  ð&ð ð ð(ð ð ð..ð .ð .ð27ð 7ð 7ð&>ð >ð >ð&ð &ð &ð&3ð 3ð 3ðPð Pð Pð Pð:Eð Eð Eð,<ð <ð <ð
,ð ,ð ,ð ,ð ,r"   