HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/site-packages/mysqlx/__pycache__/helpers.cpython-311.pyc
�

�ncH���dZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
eefZ
eeejfZdd�Zdd�Zd	�Zd
�Zdd�Zdd
�Zd�Zd�ZdS)z&This module contains helper functions.�N�)�TLS_CIPHER_SUITES�TLS_VERSIONS)�InterfaceError�utf-8c�Z�t|t��r|n|�|��S)z�Returns an encoded version of the string as a bytes object.

    Args:
        encoding (str): The encoding.

    Resturns:
        bytes: The encoded version of the string as a bytes object.
    )�
isinstance�bytes�encode��value�encodings  �0D:\Python311\Lib\site-packages\mysqlx/helpers.py�encode_to_bytesr,s)���u�e�,�,�H�5�5�%�,�,�x�2H�2H�H�c�Z�t|t��r|�|��n|S)z�Returns a string decoded from the given bytes.

    Args:
        value (bytes): The value to be decoded.
        encoding (str): The encoding.

    Returns:
        str: The value decoded from bytes.
    )r	r
�decoders  r�decode_from_bytesr8s*��&0��u�%=�%=�H�5�<�<��!�!�!�5�Hrc�\�t|t��r||nt||��S)z�Get item from dictionary or attribute from object.

    Args:
        obj (object): Dictionary or object.
        key (str): Key.

    Returns:
        object: The object for the provided key.
    )r	�dict�getattr)�obj�keys  r�get_item_or_attrrEs+��"�#�t�,�,�C�3�s�8�8�'�#�s�2C�2C�Crc�n��d��t|��dkr�fd�|D��S�|d��S)a
Escapes special characters as they are expected to be when MySQL
    receives them.
    As found in MySQL source mysys/charset.c

    Args:
        value (object): Value to be escaped.

    Returns:
        str: The value if not a string, or the escaped string.
    c��|�|St|t��r|St|ttf��r�|�dd��}|�dd��}|�dd��}|�dd	��}|�d
d��}|�dd
��}n�|�dd��}|�dd��}|�dd��}|�dd��}|�dd��}|�dd��}|S)zEscapes special characters.N�\s\\�
s\n�
s\r�'s\'�"s\"�s\�\z\\�
z\n�
z\r�'z\'�"z\"�z\)r	�
NUMERIC_TYPESr
�	bytearray�replace)r
s r�_escapezescape.<locals>._escape^s(���	��L��e�]�+�+�	��L��e�e�Y�/�0�0�
	6��M�M�%��1�1�E��M�M�%��0�0�E��M�M�%��0�0�E��M�M�'�;�7�7�E��M�M�'�;�7�7�E��M�M�'�;�7�7�E�E��M�M�$��/�/�E��M�M�$��.�.�E��M�M�$��.�.�E��M�M�&�*�5�5�E��M�M�&�*�5�5�E��M�M�&�*�5�5�E��rrc�&��g|]
}�|����S�r.)�.0�argr,s  �r�
<listcomp>zescape.<locals>.<listcomp>us!���-�-�-�������-�-�-rr)�len)�argsr,s @r�escaper4RsT������,�4�y�y�1�}�.�-�-�-�-��-�-�-�-��7�4��7���r�c�~�|dkr|�dd��}d|�d�S|�dd��}d|�d�S)acQuote the given identifier with backticks, converting backticks (`)
    in the identifier name with the correct escape sequence (``) unless the
    identifier is quoted (") as in sql_mode set to ANSI_QUOTES.

    Args:
        identifier (str): Identifier to quote.

    Returns:
        str: Returns string with the identifier quoted with backticks.
    �ANSI_QUOTESr'z""�`z``)r+)�
identifier�sql_mode�quoteds   r�quote_identifierr<ysW���=� ���#�#�C��.�.���6�}�}�}��
�
�
��T�
*�
*�F��v�=�=�=�rc������fd�}|S)a�This is a decorator used to mark functions as deprecated.

    Args:
        version (Optional[string]): Version when was deprecated.
        reason (Optional[string]): Reason or extra information to be shown.

    Usage:

    .. code-block:: python

       from mysqlx.helpers import deprecated

       @deprecated('8.0.12', 'Please use other_function() instead')
       def deprecated_function(x, y):
           return x + y
    c�L���tj������fd���}|S)zDecorate function.c�\��d�j�d�g}�r|�d������r|�d�����tj��j}tjd�|��ttj	|j
��|j����|i|��S)z�Wrapper function.

            Args:
                *args: Variable length argument list.
                **kwargs: Arbitrary keyword arguments.
            r&z' is deprecatedz since version z. r5)�category�filename�lineno)�__name__�append�inspect�currentframe�f_back�warnings�
warn_explicit�join�DeprecationWarning�getfile�f_code�f_lineno)r3�kwargs�message�frame�func�reason�versions    ���r�wrapperz-deprecated.<locals>.decorate.<locals>.wrapper�s����:�4�=�9�9�9�:�G��
<����:��:�:�;�;�;��
.����}�F�}�}�-�-�-��(�*�*�1�E��"����� � �+� ����6�6��~�	
�
�
�
��4��(��(�(�(r)�	functools�wraps)rRrUrSrTs` ��r�decoratezdeprecated.<locals>.decorate�sE����
���	�	�	)�	)�	)�	)�	)�	)�
�	�	)�*�rr.)rTrSrXs`` r�
deprecatedrY�s)����$������6�Orc�T�g}i}ttj|��dz��D]-}|�tt|���.|D]N}d|vr|�|���||vr|�||���<t
d|�d����|S)z�Translates a cipher suites names list; from IANI names to OpenSSL names.

    Args:
        TLS_version (str): The TLS version to look at for a translation.
        cipher_suite_names (list): A list of cipher suites names.
    r�-zThe 'z.' in cipher suites is not a valid cipher suite)�ranger�index�updaterrDr)�tls_version�cipher_suites_names�translated_names�
cipher_suitesr]�names      r�iani_to_openssl_cs_namerd�s������M��|�)�+�6�6��:�;�;�E�E�����.�|�E�/B�C�D�D�D�D�#�����$�;�	��#�#�D�)�)�)�)�
�]�
"�	��#�#�M�$�$7�8�8�8�8� �L��L�L�L���
��rc�P�tj|���d��S)z�Return the hexadecimal representation of the binary data.

    Args:
        data (str): The binary data.

    Returns:
        bytes: The hexadecimal representation of data.
    r)�binascii�hexlifyr)�datas rrgrg�s#����D�!�!�(�(��1�1�1r)r)r5)NN)�__doc__rf�decimalrVrErH�	constantsrr�errorsrr*r
�
BYTE_TYPES�int�float�Decimalr)rrrr4r<rYrdrgr.rr�<module>rqs"��:-�,���������������������6�6�6�6�6�6�6�6�"�"�"�"�"�"���
�
��e�W�_�-�
�	I�	I�	I�	I�
I�
I�
I�
I�
D�
D�
D�$�$�$�N����$-�-�-�-�`���6	2�	2�	2�	2�	2r