§
    £˜ºh{  ã                   ó‚  — 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j        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$dS )"z&This module contains helper functions.é    N)ÚAnyÚCallableÚListÚOptionalÚUnioné   )ÚTLS_CIPHER_SUITESÚTLS_VERSIONS)ÚInterfaceError)ÚEscapeTypesÚ
StrOrBytesúutf-8ÚvalueÚencodingÚreturnc                 ó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©r   r   s     úV/var/www/html/services/rag-service/venv/lib/python3.11/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_bytesr   ;   s*   € õ &0°µuÑ%=Ô%=ÐHˆ5�<Š<˜Ñ!Ô!Ð!À5ÐHr   ÚobjÚkeyc                 ó\   — t          | t          ¦  «        r| |         n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Ñ,Ô,ÐCˆ3ˆsŒ8ˆ8µ'¸#¸sÑ2CÔ2CÐCr   Úargsc                  óŒ   ‡— dt           dt           fd„Št          | ¦  «        dk    rˆfd„| 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.
    r   r   c                 ó†  — | €| S t          | t          ¦  «        r| S t          | t          t          f¦  «        r…|                      dd¦  «        } |                      dd¦  «        } |                      dd¦  «        } |                      dd	¦  «        } |                      d
d¦  «        } |                      dd¦  «        } n„|                      dd¦  «        } |                      dd¦  «        } |                      dd¦  «        } |                      dd¦  «        } |                      dd¦  «        } |                      dd¦  «        } | S )zEscapes 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   Ú_escapezescape.<locals>._escapea   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Øˆr   r   c                 ó&   •— g | ]} ‰|¦  «        ‘ŒS © r7   )Ú.0Úargr5   s     €r   ú
<listcomp>zescape.<locals>.<listcomp>x   s!   ø€ Ð-Ð-Ð- ��˜‘”Ð-Ð-Ð-r   r   )r   Úlen)r#   r5   s    @r   Úescaper<   U   sd   ø€ ð•{ð ¥{ð ð ð ð õ, ˆ4�y„y�1‚}€}Ø-Ð-Ð-Ð-¨Ð-Ñ-Ô-Ð-Øˆ7�4˜”7ÑÔÐr   Ú Ú
identifierÚsql_modec                 ó~   — |dk    r|                       dd¦  «        }d|› d�S |                       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_QUOTESr0   z""ú`z``)r4   )r>   r?   Úquoteds      r   Úquote_identifierrD   |   sU   € ð �=Ò Ð Ø×#Ò# C¨Ñ.Ô.ˆØ�6ˆ}ˆ}ˆ}ÐØ×Ò  TÑ*Ô*€FØˆvˆ=ˆ=ˆ=Ðr   ÚversionÚreasonc                 ó4   ‡ ‡— 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                 óx   •‡ — t          j        ‰ ¦  «        dt          dt          dt          fˆ ˆˆfd„¦   «         }|S )zDecorate function.r#   Úkwargsr   c                  ó\  •— d‰j         › d�g}‰r|                     d‰› �¦  «         ‰r|                     d‰› �¦  «         t          j        ¦   «         j        }t          j        d                     |¦  «        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. r=   )ÚcategoryÚfilenameÚlineno)Ú__name__ÚappendÚinspectÚcurrentframeÚf_backÚwarningsÚwarn_explicitÚjoinÚDeprecationWarningÚgetfileÚf_codeÚf_lineno)r#   rJ   ÚmessageÚframerH   rF   rE   s       €€€r   Úwrapperz-deprecated.<locals>.decorate.<locals>.wrapper¦   sÅ   ø€ ð :˜4œ=Ð9Ð9Ð9Ð:ˆGØð <Ø—’Ð:°Ð:Ð:Ñ;Ô;Ð;Øð .Ø—’˜} F˜}˜}Ñ-Ô-Ð-ÝÔ(Ñ*Ô*Ô1ˆEÝÔ"Ø—’˜Ñ Ô Ý+Ý œ¨¬Ñ6Ô6Ø”~ð	ñ ô ð ð �4˜Ð( Ð(Ð(Ð(r   )Ú	functoolsÚwrapsr   r   )rH   r]   rF   rE   s   ` €€r   Údecoratezdeprecated.<locals>.decorate£   s_   øø€ õ 
Œ˜Ñ	Ô	ð	)�3ð 	)­#ð 	)µ(ð 	)ð 	)ð 	)ð 	)ð 	)ð 	)ð 	)ñ 
Ô	ð	)ð* ˆr   )r   )rE   rF   r`   s   `` r   Ú
deprecatedra   Ž   s<   øø€ ð*•xð ¥Hð ð ð ð ð ð ð ð6 €Or   Útls_versionÚcipher_suites_namesc                 óT  — g }i }t          t          j        | ¦  «        dz   ¦  «        D ]-}|                     t          t          |                  ¦  «         Œ.|D ]N}d|v r|                     |¦  «         Œ||v r|                     ||         ¦  «         Œ<t          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	   rP   r   )rb   rc   Útranslated_namesÚcipher_suitesrg   Únames         r   Úiani_to_openssl_cs_namerl   Á   sÚ   € ð Ðà€Mõ •|Ô)¨+Ñ6Ô6¸Ñ:Ñ;Ô;ð Eð EˆØ×ÒÕ.­|¸EÔ/BÔCÑDÔDÐDÐDà#ð ð ˆØ�$ˆ;ˆ;Ø×#Ò# DÑ)Ô)Ð)Ð)Ø�]Ð"Ð"Ø×#Ò# M°$Ô$7Ñ8Ô8Ð8Ð8å ØL˜ÐLÐLÐLñô ð ð Ðr   Údatac                 óP   — t          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.
    r   )ÚbinasciiÚhexlifyr   )rm   s    r   rp   rp   á   s#   € õ Ô˜DÑ!Ô!×(Ò(¨Ñ1Ô1Ð1r   )r   )r=   )NN)%Ú__doc__ro   Údecimalr^   rQ   rT   Útypingr   r   r   r   r   Ú	constantsr	   r
   Úerrorsr   Útypesr   r   r3   r   Ú
BYTE_TYPESÚintÚfloatÚDecimalr2   Ústrr   r   Úobjectr"   r<   rD   ra   rl   rp   r7   r   r   ú<module>r}      sU  ðð: -Ð ,à €€€Ø €€€Ø Ð Ð Ð Ø €€€Ø €€€à 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7à 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø "Ð "Ð "Ð "Ð "Ð "Ø *Ð *Ð *Ð *Ð *Ð *Ð *Ð *à˜Ð€
Ø�e˜Wœ_Ð-€ð	Ið 	I˜:ð 	I°ð 	IÀ5ð 	Ið 	Ið 	Ið 	Ið
Ið 
I˜Zð 
I°3ð 
IÀSð 
Ið 
Ið 
Ið 
Ið
D˜&ð 
D sð 
D¨sð 
Dð 
Dð 
Dð 
Dð$�+ð $ %¨°T¸+Ô5FÐ(FÔ"Gð $ð $ð $ð $ðNð  ð °ð ¸Sð ð ð ð ð$0ð 0˜ œð 0°h¸s´mð 0Èxð 0ð 0ð 0ð 0ðfØðØ+/°¬9ðà	ˆ#„Yðð ð ð ð@	2�%ð 	2˜Cð 	2ð 	2ð 	2ð 	2ð 	2ð 	2r   