Ë
    @Øïi{  ã                   óf  — 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mZmZm	Z	m
Z
mZ ddlmZmZ ddlmZ ddlmZmZ eefZeeej2                  fZdded	ed
efd„Zdded	ed
efd„Zdeded
efd„Zded
eee	e   f   fd„Z ddeded
efd„Z!dde
e   de
e   d
efd„Z"dede	e   d
e	e   fd„Z#ded
efd„Z$y) z&This module contains helper functions.é    N)ÚAnyÚCallableÚListÚOptionalÚUnioné   )ÚTLS_CIPHER_SUITESÚTLS_VERSIONS)ÚInterfaceError)ÚEscapeTypesÚ
StrOrBytesÚvalueÚencodingÚreturnc                 óH   — t        | t        «      r| S | j                  |«      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©r   r   s     úH/var/www/html/aiagents/fe/lib/python3.12/site-packages/mysqlx/helpers.pyÚencode_to_bytesr   /   s!   € ô ˜u¤eÔ,ˆ5ÐH°%·,±,¸xÓ2HÐHó    c                 óH   — t        | t        «      r| j                  |«      S | 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_bytesr   ;   s!   € ô &0°´uÔ%=ˆ5�<‰<˜Ó!ÐHÀ5ÐHr   ÚobjÚkeyc                 óD   — t        | t        «      r| |   S t        | |«      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)r   r   s     r   Úget_item_or_attrr!   H   s#   € ô " #¤tÔ,ˆ3ˆs‰8ÐC´'¸#¸sÓ2CÐCr   Úargsc                  óŠ   — dt         dt         fd„}t        | «      dkD  r| D �cg c]
  } ||«      ‘Œ c}S  || d   «      S c c}w )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.
    r   r   c                 ó  — | €| S t        | t        «      r| S t        | t        t        f«      rn| j	                  dd«      } | j	                  dd«      } | j	                  dd«      } | j	                  dd«      } | j	                  d	d
«      } | j	                  dd«      } | S | j	                  dd«      } | j	                  dd«      } | j	                  dd«      } | j	                  dd«      } | j	                  dd«      } | j	                  dd«      } | S )zEscapes special characters.ó   \s   \\ó   
s   \nó   s   \ró   's   \'ó   "s   \"ó   s   \ú\z\\ú
z\núz\rú'z\'ú"z\"úz\)r   ÚNUMERIC_TYPESr   Ú	bytearrayÚreplace)r   s    r   Ú_escapezescape.<locals>._escapea   sø   € àˆ=ØˆLÜ�eœ]Ô+ØˆLÜ�eœe¤YÐ/Ô0Ø—M‘M %¨Ó1ˆEØ—M‘M %¨Ó0ˆEØ—M‘M %¨Ó0ˆEØ—M‘M '¨;Ó7ˆEØ—M‘M '¨;Ó7ˆEØ—M‘M '¨;Ó7ˆEð ˆð —M‘M $¨Ó/ˆEØ—M‘M $¨Ó.ˆEØ—M‘M $¨Ó.ˆEØ—M‘M &¨*Ó5ˆEØ—M‘M &¨*Ó5ˆEØ—M‘M &¨*Ó5ˆEØˆr   r   r   )r   Úlen)r"   r4   Úargs      r   Úescaper7   U   sK   € ð”{ð ¤{ó ô, ˆ4ƒy�1‚}Ø(,Ö- ‘˜•Ò-Ð-Ù�4˜‘7ÓÐùò .s   £A Ú
identifierÚsql_modec                 ól   — |dk(  r| j                  dd«      }d|› d�S | j                  dd«      }d|› d�S )ac  Quote 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``)r3   )r8   r9   Úquoteds      r   Úquote_identifierr>   |   sL   € ð �=Ò Ø×#Ñ# C¨Ó.ˆØ�6�(˜!ˆ}ÐØ×Ñ  TÓ*€FØˆvˆh�aˆ=Ðr   ÚversionÚreasonc                 ó0   ‡ ‡— dt         dt         fˆˆ fd„}|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.

    Returns:
        Callable: A decorator used to mark functions as deprecated.

    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
    Úfuncr   c                 ón   •‡ — t        j                  ‰ «      dt        dt        dt        fˆ ˆˆfd„«       }|S )zDecorate function.r"   Úkwargsr   c                  óp  •— d‰j                   › d�g}‰r|j                  d‰› �«       ‰r|j                  d‰› �«       t        j                  «       j                  }t        j                  dj                  |«      t        t        j                  |j                  «      |j                  ¬«        ‰| i |¤ŽS )zžWrapper function.

            Args:
                *args: Variable length argument list.
                **kwargs: Arbitrary keyword arguments.
            r.   z' is deprecatedz since version z. Ú )ÚcategoryÚfilenameÚlineno)Ú__name__ÚappendÚinspectÚcurrentframeÚf_backÚwarningsÚwarn_explicitÚjoinÚDeprecationWarningÚgetfileÚf_codeÚf_lineno)r"   rD   ÚmessageÚframerB   r@   r?   s       €€€r   Úwrapperz-deprecated.<locals>.decorate.<locals>.wrapper¦   sŸ   ø€ ð ˜4Ÿ=™=˜/¨Ð9Ð:ˆGÙØ—‘ °°	Ð:Ô;ÙØ—‘  F 8˜}Ô-Ü×(Ñ(Ó*×1Ñ1ˆEÜ×"Ñ"Ø—‘˜Ó Ü+Ü Ÿ™¨¯©Ó6Ø—~‘~õ	ñ ˜Ð( Ñ(Ð(r   )Ú	functoolsÚwrapsr   r   )rB   rX   r@   r?   s   ` €€r   Údecoratezdeprecated.<locals>.decorate£   s<   ù€ ô 
�‰˜Ó	ð	)œ3ð 	)¬#ð 	)´(ö 	)ó 
ð	)ð* ˆr   )r   )r?   r@   r[   s   `` r   Ú
deprecatedr\   Ž   s   ù€ ð*”xð ¤Hö ð6 €Or   Útls_versionÚcipher_suites_namesc                 ó   — g }i }t        t        j                  | «      dz   «      D ]!  }|j                  t        t        |      «       Œ# |D ]?  }d|v r|j                  |«       Œ||v r|j                  ||   «       Œ2t        d|› d�«      ‚ |S )a  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.

    Returns:
        List[str]: List of translated names.
    r   ú-zThe 'z.' in cipher suites is not a valid cipher suite)Úranger
   ÚindexÚupdater	   rK   r   )r]   r^   Útranslated_namesÚcipher_suitesrb   Únames         r   Úiani_to_openssl_cs_namerg   Á   s³   € ð Ðà€Mô ”|×)Ñ)¨+Ó6¸Ñ:Ó;ò EˆØ×ÑÔ.¬|¸EÑ/BÑCÕDðEð $ò ˆØ�$‰;Ø×#Ñ# DÕ)Ø�]Ñ"Ø×#Ñ# M°$Ñ$7Õ8ä Ø˜�vÐKÐLóð ðð Ðr   Údatac                 óJ   — t        j                  | «      j                  d«      S )z»Return the hexadecimal representation of the binary data.

    Args:
        data (bytes): The binary data.

    Returns:
        str: The decoded hexadecimal representation of data.
    úutf-8)ÚbinasciiÚhexlifyr   )rh   s    r   rl   rl   á   s    € ô ×Ñ˜DÓ!×(Ñ(¨Ó1Ð1r   )rj   )rF   )NN)%Ú__doc__rk   ÚdecimalrY   rL   rO   Útypingr   r   r   r   r   Ú	constantsr	   r
   Úerrorsr   Útypesr   r   r2   r   Ú
BYTE_TYPESÚintÚfloatÚDecimalr1   Ústrr   r   Úobjectr!   r7   r>   r\   rg   rl   © r   r   ú<module>rz      s5  ðñ: -ã Û Û Û Û ç 7Õ 7ç 6Ý "ß *à˜Ð€
Ø�e˜WŸ_™_Ð-€ñ	I˜:ð 	I°ð 	IÀ5ó 	Iñ
I˜Zð 
I°3ð 
IÀSó 
Ið
D˜&ð 
D sð 
D¨só 
Dð$�+ð $ %¨°T¸+Ñ5FÐ(FÑ"Gó $ñN ð °ð ¸Só ñ$0˜ ™ð 0°h¸s±mð 0Èxó 0ðfØðØ+/°©9ðà	ˆ#�Yóð@	2�%ð 	2˜Cô 	2r   