HEX
Server: LiteSpeed
System: Linux server.nevid-deploma.com 4.18.0-553.111.1.lve.el8.x86_64 #1 SMP Fri Mar 13 13:42:17 UTC 2026 x86_64
User: smilepac (1037)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cppython/lib/python3.8/site-packages/oauth2client/__pycache__/_helpers.cpython-38.pyc
U

KD�gd*�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
e�e�Z
dZdZdZeeeeg�ZeZdZdZd	Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd%dd�Z dd �Z!d!d"�Z"d#d$�Z#dS)&z-Helper functions for commonly used utilities.�N)�urllib�WARNINGZ	EXCEPTIONZIGNOREzFile: {0}: Is a symbolic link.z{0}: Is a directoryz,Cannot access {0}: No such file or directorycsJ�fdd�}t�tj�r|St���\}}}}tt|�t|����SdS)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.
    cst�����fdd��}|S)Ncsbt|��krXd}�dkrd}dj�j�t|�|d�}ttkrFt|��nttkrXt�|��||�S)N���szV{function}() takes at most {args_max} positional argument{plural} ({args_given} given))�functionZargs_maxZ
args_given�plural)	�len�format�__name__�!positional_parameters_enforcement�POSITIONAL_EXCEPTION�	TypeError�POSITIONAL_WARNING�logger�warning)�args�kwargsZplural_s�message)�max_positional_args�wrapped��B/opt/cppython/lib/python3.8/site-packages/oauth2client/_helpers.py�positional_wrapperus�

zDpositional.<locals>.positional_decorator.<locals>.positional_wrapper)�	functools�wraps)rr�r)rr�positional_decoratortsz(positional.<locals>.positional_decoratorN)�
isinstance�six�
integer_types�inspect�
getargspec�
positionalr	)rrr�_�defaultsrrrr#,s
Hr#cCst|tj�r|Sd�|�SdS)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.
    � N)rr�string_types�join�Zscopesrrr�scopes_to_string�s
r*cCs&|sgSt|tj�r|�d�S|SdS)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&N)rrr'�splitr)rrr�string_to_scopes�s

r,cCsZtj�|�}i}t�|�D]:\}}t|�dkrHd|d�|�f}t|��|d||<q|S)aParses 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.
    rz6URL-encoded content contains a repeated value:%s -> %sz, r)r�parse�parse_qsr�	iteritemsr	r(�
ValueError)�contentZurlencoded_params�params�key�value�msgrrr�parse_unique_urlencoded�s�r6cCsDtj�|�}t|j�}|�|�tj�|�}|j|d�}tj�|�S)aUpdates 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)	rr-�urlparser6r7�update�	urlencode�_replace�
urlunparse)�urir2�partsZquery_paramsZ	new_queryZ	new_partsrrr�update_query_params�s

r?cCs|dkr|St|||i�SdS)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.
    N)r?)�url�namer4rrr�_add_query_parameter�s
rBcCsXtj�|�rtt�|���n8tj�|�r8tt�|���ntj�|�sTt	�
t�|��dS)N)�os�path�islink�IOError�_SYM_LINK_MESSAGEr
�isdir�_IS_DIR_MESSAGE�isfile�warnings�warn�_MISSING_FILE_MESSAGE)�filenamerrr�
validate_file�srOcCs"|�d�}|dkr||d�SdS)azIdentify 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)Z
raw_key_input�offsetrrr�_parse_pem_keys
rScCstj|dd�S)N)�,�:)�
separators)�json�dumps)�datarrr�_json_encodesrZ�asciicCs<t|tj�r|�|�n|}t|tj�r*|Std�|���dS)a4Converts 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 bytesN)rr�	text_type�encode�binary_typer0r
)r4�encoding�resultrrr�	_to_bytess
��racCs<t|tj�r|�d�n|}t|tj�r*|Std�|���dS)aEConverts 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 unicodeN)rrr^�decoder\r0r
)r4r`rrr�_from_bytes6s
���rdcCst|dd�}t�|��d�S)Nrb)r_�=)ra�base64�urlsafe_b64encode�rstrip)Z	raw_bytesrrr�_urlsafe_b64encodeLsricCs*t|�}|ddt|�d}t�|�S)Nre�)rar	rf�urlsafe_b64decode)Z	b64string�paddedrrr�_urlsafe_b64decodeQsrm)r[)$�__doc__rfrr!rW�loggingrCrKrZ	six.movesr�	getLoggerrrrr
ZPOSITIONAL_IGNORE�	frozensetZPOSITIONAL_SETrrGrIrMr#r*r,r6r?rBrOrSrZrardrirmrrrr�<module>sB
�c