HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib64/python3.10/site-packages/google/auth/__pycache__/_helpers.cpython-310.pyc
o

�h, �@s�dZddlZddlZddlZddlmZddlZddlZddlm	Z	ej
ddd�Zdd	�Zd
d�Z
dd
�Zdd�Zd!dd�Zdd�Zd"dd�Zdd�Zdd�Zdd�Zdd�Zdd �ZdS)#z-Helper functions for commonly used utilities.�N)�Message)�
exceptions��-)�minutes�secondscs�fdd�}|S)a0Decorator that copies a method's docstring from another class.

    Args:
        source_class (type): The class that has the documented method.

    Returns:
        Callable: A decorator that will copy the docstring of the same
            named method in the source class to the decorated method.
    cs(|jrt�d��t�|j�}|j|_|S)a?Decorator implementation.

        Args:
            method (Callable): The method to copy the docstring to.

        Returns:
            Callable: the same method passed in with an updated docstring.

        Raises:
            google.auth.exceptions.InvalidOperation: if the method already has a docstring.
        zMethod already has a docstring.)�__doc__r�InvalidOperation�getattr�__name__)�method�
source_method��source_class��G/usr/local/CyberCP/lib/python3.10/site-packages/google/auth/_helpers.py�	decorator*s

z!copy_docstring.<locals>.decoratorr)rrrrr�copy_docstringsrcCst�}||d<|��S)aParse a 'content-type' header value to get just the plain media-type (without parameters).

    This is done using the class Message from email.message as suggested in PEP 594
        (because the cgi is now deprecated and will be removed in python 3.13,
        see https://peps.python.org/pep-0594/#cgi).

    Args:
        header_value (str): The value of a 'content-type' header as a string.

    Returns:
        str: A string with just the lowercase media-type from the parsed 'content-type' header.
            If the provided content-type is not parsable, returns 'text/plain',
            the default value for textual files.
    zcontent-type)r�get_content_type)�header_value�mrrr�parse_content_typeAs�rcCs tj�tjj�}|jdd�}|S)z_Returns the current UTC datetime.

    Returns:
        datetime: The current time in UTC.
    N)�tzinfo)�datetime�now�timezone�utc�replace)rrrr�utcnowWsrcCst�|���S)z�Convert a datetime object to the number of seconds since the UNIX epoch.

    Args:
        value (datetime): The datetime to convert.

    Returns:
        int: The number of seconds since the UNIX epoch.
    )�calendar�timegm�utctimetuple��valuerrr�datetime_to_secsgs	r$�utf-8cCs6t|t�r
|�|�n|}t|t�r|St�d�|���)a�Converts a string value to bytes, if necessary.

    Args:
        value (Union[str, bytes]): The value to be converted.
        encoding (str): The encoding to use to convert unicode to bytes.
            Defaults to "utf-8".

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

    Raises:
        google.auth.exceptions.InvalidValue: If the value could not be converted to bytes.
    z%{0!r} could not be converted to bytes)�
isinstance�str�encode�bytesr�InvalidValue�format)r#�encoding�resultrrr�to_bytesss
�r.cCs6t|t�r
|�d�n|}t|t�r|St�d�|���)aoConverts bytes to a string value, if necessary.

    Args:
        value (Union[str, bytes]): The value to be converted.

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

    Raises:
        google.auth.exceptions.InvalidValue: If the value could not be converted to unicode.
    r%z'{0!r} could not be converted to unicode)r&r)�decoder'rr*r+)r#r-rrr�
from_bytes�s
�r0csn�durg�tj�|�}tj�|j�}|�|��fdd�|��D�}tjj|dd�}|j|d�}tj�	|�S)a�Updates a URL's query parameters.

    Replaces any current values if they are already present in the URL.

    Args:
        url (str): The URL to update.
        params (Mapping[str, str]): A mapping of query parameter
            keys to values.
        remove (Sequence[str]): Parameters to remove from the query string.

    Returns:
        str: The URL with updated query parameters.

    Examples:

        >>> url = 'http://example.com?a=1'
        >>> update_query(url, {'a': '2'})
        http://example.com?a=2
        >>> update_query(url, {'b': '3'})
        http://example.com?a=1&b=3
        >> update_query(url, {'b': '3'}, remove=['a'])
        http://example.com?b=3

    Ncsi|]\}}|�vr||�qSrr)�.0�keyr#��removerr�
<dictcomp>�sz update_query.<locals>.<dictcomp>T)�doseq)�query)
�urllib�parse�urlparse�parse_qsr7�update�items�	urlencode�_replace�
urlunparse)�url�paramsr4�parts�query_params�	new_query�	new_partsrr3r�update_query�s

�rGcCs
d�|�S)z�Converts scope value to a string suitable for sending to OAuth 2.0
    authorization servers.

    Args:
        scopes (Sequence[str]): The sequence of scopes to convert.

    Returns:
        str: The scopes formatted as a single string.
    � )�join��scopesrrr�scopes_to_string�s

rLcCs|sgS|�d�S)z�Converts stringifed scopes value to a list.

    Args:
        scopes (Union[Sequence, str]): The string of space-separated scopes
            to convert.
    Returns:
        Sequence(str): The separated scopes.
    rH)�splitrJrrr�string_to_scopes�s	
rNcCs(t|�}|dt|�d}t�|�S)z�Decodes base64 strings lacking padding characters.

    Google infrastructure tends to omit the base64 padding characters.

    Args:
        value (Union[str, bytes]): The encoded value.

    Returns:
        bytes: The decoded value
    �=�)r.�len�base64�urlsafe_b64decode)r#�	b64string�paddedrrr�padded_urlsafe_b64decode�s
rVcCst�|��d�S)auEncodes base64 strings removing any padding characters.

    `rfc 7515`_ defines Base64url to NOT include any padding
    characters, but the stdlib doesn't do that by default.

    _rfc7515: https://tools.ietf.org/html/rfc7515#page-6

    Args:
        value (Union[str|bytes]): The bytes-like value to encode

    Returns:
        Union[str|bytes]: The encoded value
    rO)rR�urlsafe_b64encode�rstripr"rrr�unpadded_urlsafe_b64encode�srYcCs
tjdkS)z�Check if the Python interpreter is Python 2 or 3.

    Returns:
        bool: True if the Python interpreter is Python 3 and False otherwise.
    )rr)�sys�version_inforrrr�is_python_3s
r\)r%)N)rrRrr�
email.messagerrZr8�google.authr�	timedelta�REFRESH_THRESHOLDrrrr$r.r0rGrLrNrVrYr\rrrr�<module>s*"

-