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/botocore/__pycache__/useragent.cpython-38.pyc
U

KD�g�V�@s(dZddlZddlZddlZddlmZddlmZmZddlm	Z	m
Z
ddlmZ
ddlmZddlmZe�e�Zeed	Zd
ZddiZd
Zdddddd�Zdd�Zdd�ZGdd�d�ZGdd�de	�ZGdd�d�Zzddlm Z Wne!k
�rdd �Z YnXGd!d"�d"�Z"d#d$�Z#dS)%a�
NOTE: All classes and functions in this module are considered private and are
subject to abrupt breaking changes. Please do not use them directly.

To modify the User-Agent header sent by botocore, use one of these
configuration options:
* The ``AWS_SDK_UA_APP_ID`` environment variable.
* The ``sdk_ua_app_id`` setting in the shared AWS config file.
* The ``user_agent_appid`` field in the :py:class:`botocore.config.Config`.
* The ``user_agent_extra`` field in the :py:class:`botocore.config.Config`.

�N)�copy)�
ascii_letters�digits)�
NamedTuple�Optional)�__version__)�HAS_CRT)�get_contextz!$%&'*+-.^_`|~,)�windows�linux�macosZandroid�iosZwatchosZtvos�other�darwinrZBotocore�B�C�G�N�S)ZWAITERZ	PAGINATORZS3_TRANSFERZENDPOINT_OVERRIDEZSIGV4A_SIGNINGcCs0t�}|dkrdSt�|�}r,|j�|�dS)z�Adds metric value to the current context object's ``features`` set.

    :type feature_id: str
    :param feature_id: The name of the feature to register. Value must be a key
        in the ``_USERAGENT_FEATURE_MAPPINGS`` dict.
    N)r	�_USERAGENT_FEATURE_MAPPINGS�get�features�add)Z
feature_id�ctx�val�r�?/opt/cppython/lib/python3.8/site-packages/botocore/useragent.py�register_feature_idBs
rcsd��fdd�|D��S)a~Replaces all not allowed characters in the string with a dash ("-").

    Allowed characters are ASCII alphanumerics and ``!$%&'*+-.^_`|~,``. If
    ``allow_hash`` is ``True``, "#"``" is also allowed.

    :type raw_str: str
    :param raw_str: The input string to be sanitized.

    :type allow_hash: bool
    :param allow_hash: Whether "#" is considered an allowed character.
    �c3s*|]"}|tks�r|dkr|ndVqdS)�#�-N)�_USERAGENT_ALLOWED_CHARACTERS)�.0�c��
allow_hashrr�	<genexpr>as����z7sanitize_user_agent_string_component.<locals>.<genexpr>)�join)Zraw_strr%rr$r�$sanitize_user_agent_string_componentUs�r(c@s(eZdZdZeed�dd�Zdd�ZdS)�UserAgentComponentSizeConfigz�
    Configures the max size of a built user agent string component and the
    delimiter used to truncate the string if the size is above the max.
    )�max_size_in_bytes�	delimitercCs||_||_|��dS�N)r*r+�_validate_input)�selfr*r+rrr�__init__osz%UserAgentComponentSizeConfig.__init__cCs |jdkrtd|j�d���dS)N�zInvalid `max_size_in_bytes`: z#. Value must be a positive integer.)r*�
ValueError�r.rrrr-ts
�z,UserAgentComponentSizeConfig._validate_inputN)�__name__�
__module__�__qualname__�__doc__�int�strr/r-rrrrr)isr)c@sReZdZUdZeed<eed<dZeeed<dZee	ed<dd�Z
d	d
�ZdS)�UserAgentComponenta�
    Component of a Botocore User-Agent header string in the standard format.

    Each component consists of a prefix, a name, a value, and a size_config.
    In the string representation these are combined in the format
    ``prefix/name#value``.

    ``size_config`` configures the max size and truncation strategy for the
    built user agent string component.

    This class is considered private and is subject to abrupt breaking changes.
    �prefix�nameN�value�size_configcCs�t|jdd�}t|jdd�}|jdks0|jdkr@|�d|��}n"t|jdd�}|�d|�d|��}|jdk	r�|�||jj|jj�}|S)zACreate string like 'prefix/name#value' from a UserAgentComponent.Tr$FNr�/r)r(r:r;r<r=�_truncate_stringr*r+)r.Zclean_prefixZ
clean_nameZclean_stringZclean_valuerrr�	to_string�s,���
�zUserAgentComponent.to_stringc	Cs^|}t|�d��|kr4|�|�}|��|�|�}q|dkrZt�d|�d|�d|�d��|S)zx
        Pop ``delimiter``-separated values until encoded string is less than or
        equal to ``max_size``.
        zutf-8rzUser agent component `z` could not be truncated to `z` bytes with delimiter `zL` without losing all contents. Value will be omitted from user agent string.)�len�encode�split�popr'�logger�debug)r.�string�max_sizer+�orig�partsrrrr?�s
�z#UserAgentComponent._truncate_string)r3r4r5r6r8�__annotations__r<rr=r)r@r?rrrrr9|s

r9c@s eZdZdZdd�Zdd�ZdS)�RawStringUserAgentComponentz�
    UserAgentComponent interface wrapper around ``str``.

    Use for User-Agent header components that are not constructed from
    prefix+name+value but instead are provided as strings. No sanitization is
    performed.
    cCs
||_dSr,��_value)r.r<rrrr/�sz$RawStringUserAgentComponent.__init__cCs|jSr,rMr2rrrr@�sz%RawStringUserAgentComponent.to_stringN)r3r4r5r6r/r@rrrrrL�srL)�modify_componentscCs|Sr,r)�
componentsrrrrO�srOc@s�eZdZdZd%dd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdS)&�UserAgentStringaU
    Generator for AWS SDK User-Agent header strings.

    The User-Agent header format contains information from session, client, and
    request context. ``UserAgentString`` provides methods for collecting the
    information and ``to_string`` for assembling it into the standardized
    string format.

    Example usage:

        ua_session = UserAgentString.from_environment()
        ua_session.set_session_config(...)
        ua_client = ua_session.with_client_config(Config(...))
        ua_string = ua_request.to_string()

    For testing or when information from all sources is available at the same
    time, the methods can be chained:

        ua_string = (
            UserAgentString
            .from_environment()
            .set_session_config(...)
            .with_client_config(Config(...))
            .to_string()
        )

    NcCsL||_||_||_||_||_||_||_d|_d|_d|_	d|_
d|_dS)a�
        :type platform_name: str
        :param platform_name: Name of the operating system or equivalent
            platform name. Should be sourced from :py:meth:`platform.system`.
        :type platform_version: str
        :param platform_version: Version of the operating system or equivalent
            platform name. Should be sourced from :py:meth:`platform.version`.
        :type platform_machine: str
        :param platform_version: Processor architecture or machine type. For
        example "x86_64". Should be sourced from :py:meth:`platform.machine`.
        :type python_version: str
        :param python_version: Version of the python implementation as str.
            Should be sourced from :py:meth:`platform.python_version`.
        :type python_implementation: str
        :param python_implementation: Name of the python implementation.
            Should be sourced from :py:meth:`platform.python_implementation`.
        :type execution_env: str
        :param execution_env: The value of the AWS execution environment.
            Should be sourced from the ``AWS_EXECUTION_ENV` environment
            variable.
        :type crt_version: str
        :param crt_version: Version string of awscrt package, if installed.
        N)�_platform_name�_platform_version�_platform_machine�_python_version�_python_implementation�_execution_env�_crt_version�_session_user_agent_name�_session_user_agent_version�_session_user_agent_extra�_client_config�_client_features)r.�
platform_name�platform_version�platform_machine�python_version�python_implementation�
execution_env�crt_versionrrrr/�s!zUserAgentString.__init__c	CsDd}trt�pd}|t��t��t��t��t��tj	�
d�|d�S)N�UnknownZAWS_EXECUTION_ENV)r^r_r`rarbrcrd)r�_get_crt_version�platform�system�release�machinerarb�os�environr)�clsrdrrr�from_environment%s

�z UserAgentString.from_environmentcCs||_||_||_|S)ax
        Set the user agent configuration values that apply at session level.

        :param user_agent_name: The user agent name configured in the
            :py:class:`botocore.session.Session` object. For backwards
            compatibility, this will always be at the beginning of the
            User-Agent string, together with ``user_agent_version``.
        :param user_agent_version: The user agent version configured in the
            :py:class:`botocore.session.Session` object.
        :param user_agent_extra: The user agent "extra" configured in the
            :py:class:`botocore.session.Session` object.
        )rYrZr[)r.Zsession_user_agent_nameZsession_user_agent_versionZsession_user_agent_extrarrr�set_session_config4sz"UserAgentString.set_session_configcCs
||_dS)z�
        Persist client-specific features registered before or during client
        creation.

        :type features: Set[str]
        :param features: A set of client-specific features.
        N)r])r.rrrr�set_client_featuresKsz#UserAgentString.set_client_featurescCst|�}||_|S)z�
        Create a copy with all original values and client-specific values.

        :type client_config: botocore.config.Config
        :param client_config: The client configuration object.
        )rr\)r.Z
client_config�cprrr�with_client_configUsz"UserAgentString.with_client_configcCs�d}|jr(t|jd�r |jj}n|jj}|dk	r:|�|�S|��td�f|��|��|�	�|�
�|��|��|�
�|���
}t|�}d�dd�|D��S)zN
        Build User-Agent header string from the object's properties.
        N�_supplied_user_agentzua/2.1� cSsg|]}|��r|���qSr)r@)r"�comprrr�
<listcomp>~sz-UserAgentString.to_string.<locals>.<listcomp>)r\�hasattrrs�
user_agent�_build_legacy_ua_string�_build_sdk_metadatarL�_build_os_metadata�_build_architecture_metadata�_build_language_metadata�_build_execution_env_metadata�_build_feature_metadata�_build_config_metadata�
_build_app_id�_build_extrarOr'�r.Zconfig_ua_overriderPrrrr@`s.

��
�zUserAgentString.to_stringcCsxg}|jrF|jrF|jtks$|jtkrF|�t|j|j�tdtt�g�n|�ttt��|jdk	rt|�tdd|j��|S)at
        Build the SDK name and version component of the User-Agent header.

        For backwards-compatibility both session-level and client-level config
        of custom tool names are honored. If this removes the Botocore
        information from the start of the string, Botocore's name and version
        are included as a separate field with "md" prefix.
        �mdN�awscrt)rYrZ�_USERAGENT_SDK_NAME�botocore_version�extendr9�appendrX)r.Zsdk_mdrrrrz�s:	���������
�z#UserAgentString._build_sdk_metadatacCsz|jdkrtdd�gS|j��}|tkr.|}n|tkr@t|}nd}|dk	r\td||j�gStdd�td|j|j�gSdS)a"
        Build the OS/platform components of the User-Agent header string.

        For recognized platform names that match or map to an entry in the list
        of standardized OS names, a single component with prefix "os" is
        returned. Otherwise, one component "os/other" is returned and a second
        with prefix "md" and the raw platform name.

        String representations of example return values:
         * ``os/macos#10.13.6``
         * ``os/linux``
         * ``os/other``
         * ``os/other md/foobar#1.2.3``
        Nrkrr�)rRr9�lower�_USERAGENT_ALLOWED_OS_NAMES�!_USERAGENT_PLATFORM_NAME_MAPPINGSrS)r.Zplt_name_lowerZ	os_familyrrrr{�s$


���z"UserAgentString._build_os_metadatacCs|jrtdd|j���gSgS)z�
        Build architecture component of the User-Agent header string.

        Returns the machine type with prefix "md" and name "arch", if one is
        available. Common values include "x86_64", "arm64", "i386".
        r��arch)rTr9r�r2rrrr|�s��z,UserAgentString._build_architecture_metadatacCs.tdd|j�g}|jr*|�tdd|j��|S)a�
        Build the language components of the User-Agent header string.

        Returns the Python version in a component with prefix "lang" and name
        "python". The Python implementation (e.g. CPython, PyPy) is returned as
        separate metadata component with prefix "md" and name "pyimpl".

        String representation of an example return value:
        ``lang/python#3.10.4 md/pyimpl#CPython``
        �lang�pythonr�Zpyimpl)r9rUrVr�)r.Zlang_mdrrrr}�s��z(UserAgentString._build_language_metadatacCs|jrtd|j�gSgSdS)z�
        Build the execution environment component of the User-Agent header.

        Returns a single component prefixed with "exec-env", usually sourced
        from the environment variable AWS_EXECUTION_ENV.
        zexec-envN)rWr9r2rrrr~�sz-UserAgentString._build_execution_env_metadatacCsXt�}|dkrt�n|j}|jp$t�}|�|�}|s8gStdd�}tdd�|�|d�gS)z�
        Build the features component of the User-Agent header string.

        Returns a single component with prefix "m" followed by a list of
        comma-separated metric values.
        Ni�,�m)r=)r	�setrr]�unionr)r9r')r.rZcontext_featuresZclient_featuresrr=rrrr�s

��z'UserAgentString._build_feature_metadatacCsJ|jr|jjsgS|jj�d�}tdd|�g}|jjrF|�tdd��|S)a
        Build the configuration components of the User-Agent header string.

        Returns a list of components with prefix "cfg" followed by the config
        setting name and its value. Tracked configuration settings may be
        added or removed in future versions.
        �mode�cfgz
retry-modezendpoint-discovery)r\�retriesrr9Zendpoint_discovery_enabledr�)r.Z
retry_modeZcfg_mdrrrr�sz&UserAgentString._build_config_metadatacCs&|jr|jjrtd|jj�gSgSdS)a�
        Build app component of the User-Agent header string.

        Returns a single component with prefix "app" and value sourced from the
        ``user_agent_appid`` field in :py:class:`botocore.config.Config` or
        the ``sdk_ua_app_id`` setting in the shared configuration file, or the
        ``AWS_SDK_UA_APP_ID`` environment variable. These are the recommended
        ways for apps built with Botocore to insert their identifer into the
        User-Agent header.
        ZappN)r\Zuser_agent_appidr9r2rrrr�#s�zUserAgentString._build_app_idcCs>g}|jr|�t|j��|jr:|jjr:|�t|jj��|S)a�User agent string components based on legacy "extra" settings.

        Creates components from the session-level and client-level
        ``user_agent_extra`` setting, if present. Both are passed through
        verbatim and should be appended at the end of the string.

        Preferred ways to inject application-specific information into
        botocore's User-Agent header string are the ``user_agent_appid` field
        in :py:class:`botocore.config.Config`. The ``AWS_SDK_UA_APP_ID``
        environment variable and the ``sdk_ua_app_id`` configuration file
        setting are alternative ways to set the ``user_agent_appid`` config.
        )r[r�rLr\�user_agent_extra)r.�extrarrrr�5s
���zUserAgentString._build_extracCs8|g}|jr|�|j�|jjr.|�|jj�d�|�S)Nrt)r[r�r\r�r'r�rrrryOsz'UserAgentString._build_legacy_ua_stringcKs&|��}|j�d�r"|j�d|�dS)Nz
User-Agent)r@�headersr�replace_header)r.Zoperation_name�request�kwargsZ	ua_stringrrr�&rebuild_and_replace_user_agent_handlerWsz6UserAgentString.rebuild_and_replace_user_agent_handler)N)r3r4r5r6r/�classmethodrnrorprrr@rzr{r|r}r~rr�r�r�ryr�rrrrrQ�s($�
3

!)&rQcCs,zddl}|jWStk
r&YdSXdS)z\
    This function is considered private and is subject to abrupt breaking
    changes.
    rN)r�r�AttributeError)r�rrrrf_s
rf)$r6�loggingrkrgrrGrr�typingrrZbotocorerr�Zbotocore.compatrZbotocore.contextr	�	getLoggerr3rEr!r�r�r�rrr(r)r9rLZ!botocore.customizations.useragentrO�ImportErrorrQrfrrrr�<module>
sD


�	?