
    :?h{                     ~   S r SSKrSSKrSSKrSSKrSSKrSSKJrJrJ	r	J
r
Jr  SSKJrJr  SSKJr  SSKJrJr  \\4r\\\R2                  4rSS\S	\S
\4S jjrSS\S	\S
\4S jjrS\S\S
\4S jrS\S
\\\	\   4   4S jr SS\S\S
\4S jjr!SS\
\   S\
\   S
\4S jjr"S\S\	\   S
\	\   4S jr#S\S
\4S jr$g) z&This module contains helper functions.    N)AnyCallableListOptionalUnion   )TLS_CIPHER_SUITESTLS_VERSIONS)InterfaceError)EscapeTypes
StrOrBytesvalueencodingreturnc                 R    [        U [        5      (       a  U $ U R                  U5      $ )zReturns 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     V/var/www/ev-aguas/ev-aguas-proceso/venv/lib/python3.13/site-packages/mysqlx/helpers.pyencode_to_bytesr   /   s$     ue,,5H%,,x2HH    c                 R    [        U [        5      (       a  U R                  U5      $ U $ )zReturns 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<<!H5Hr   objkeyc                 J    [        U [        5      (       a  X   $ [        X5      $ )zGet 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,,38C'#2CCr   argsc                      S[         S[         4S jn[        U 5      S:  a  U  Vs/ sH
  o!" U5      PM     sn$ U" U S   5      $ s  snf )zEscapes 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                 (   U c  U $ [        U [        5      (       a  U $ [        U [        [        45      (       an  U R	                  SS5      n U R	                  SS5      n U R	                  SS5      n U R	                  SS5      n U R	                  S	S
5      n U R	                  SS5      n U $ U R	                  SS5      n U R	                  SS5      n U R	                  SS5      n U R	                  SS5      n U R	                  SS5      n U R	                  SS5      n U $ )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   _escapeescape.<locals>._escapea   s    =Le]++LeeY/00MM%1EMM%0EMM%0EMM';7EMM';7EMM';7E  MM$/EMM$.EMM$.EMM&*5EMM&*5EMM&*5Er   r   r   )r   len)r"   r4   args      r   escaper8   U   sO    { { , 4y1}(,---47 .s   A
identifiersql_modec                 n    US:X  a  U R                  SS5      nSU S3$ U R                  SS5      nSU S3$ )aG  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   )r9   r:   quoteds      r   quote_identifierr?   |   sL     = ##C.6(!}T*Fvha=r   versionreasonc                 4   ^ ^ S[         S[         4UU 4S jjnU$ )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                 t   >^  [         R                  " T 5      S[        S[        S[        4U UU4S jj5       nU$ )zDecorate function.r"   kwargsr   c                    > STR                    S3/nT(       a  UR                  ST 35        T(       a  UR                  ST 35        [        R                  " 5       R                  n[
        R                  " SR                  U5      [        [        R                  " UR                  5      UR                  S9  T" U 0 UD6$ )znWrapper 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"   rE   messageframerC   rA   r@   s       r   wrapper-deprecated.<locals>.decorate.<locals>.wrapper   s     4==/9:G	:;F8}-((*11E"" + 6~~	 (((r   )	functoolswrapsr   r   )rC   rY   rA   r@   s   ` r   decoratedeprecated.<locals>.decorate   sA     
		)3 	)# 	)( 	) 	) 
	)* r   )r   )r@   rA   r]   s   `` r   
deprecatedr_      s"    *x H  6 Or   tls_versioncipher_suites_namesc                 0   / n0 n[        [        R                  " U 5      S-   5       H"  nUR                  [        [        U      5        M$     U HC  nSU;   a  UR                  U5        M  XS;   a  UR                  X5   5        M6  [        SU S35      e   U$ )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	   rL   r   )r`   ra   translated_namescipher_suitesre   names         r   iani_to_openssl_cs_namerj      s     M |))+6:;.|E/BCD < $$;##D)"##M$78 vKL  $ r   datac                 L    [         R                  " U 5      R                  S5      $ )zReturn 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   )rk   s    r   ro   ro      s      D!((11r   )rm   )rG   )NN)%__doc__rn   decimalr[   rM   rP   typingr   r   r   r   r   	constantsr	   r
   errorsr   typesr   r   r2   r   
BYTE_TYPESintfloatDecimalr1   strr   r   objectr!   r8   r?   r_   rj   ro    r   r   <module>r}      s5  : -      7 7 6 " *
eW__-	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hsm 0x 0f+/9	#Y@	2% 	2C 	2r   