File: D:/Python311/Lib/site-packages/mysql/connector/__pycache__/utils.cpython-311.pyc
�
�nc�I � �p � d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl m
Z
ddlmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ dZeeeefZd � Z d
� Z!d� Z"d� Z#d
� Z$d� Z%d� Z&d� Z'd� Z(d� Z)d� Z*d&d�Z+d� Z,d� Z-d� Z.d'd�Z/d� Z0d� Z1d� Z2d� Z3d� Z4d� Z5d � Z6d!� Z7d(d$�Z8 e
� � d%� � � Z9dS ))z
Utilities.� N)�Decimal)� lru_cache)�in_table_a1�in_table_b1�in_table_c3�in_table_c4�in_table_c5�in_table_c6�in_table_c7�in_table_c8�in_table_c9�in_table_c11�in_table_c12�in_table_c21_c22�in_table_d1�in_table_d2� )�
HexLiteralFc � � t | t � � r| S t | � � }|dk r| d S |dk r&| dd|z
z z }t j d|� � d S | dd|z
z z }t j d|� � d S )z&Unpacks the given buffer to an integerr r � � �<I� �<Q)�
isinstance�int�len�struct�unpack)�buf�length�tmps �7D:\Python311\Lib\site-packages\mysql/connector/utils.py�intreadr$ @ s� � ��#�s��� ��
�
��X�X�F�
��{� ��1�v�
�
��{� +��G�q�6�z�*�*���}�T�3�'�'��*�*�
��1�v�:�&�
&�C��=��s�#�#�A�&�&� c �| � | dk s| dk rt d� � �t t j d| � � � � S )z^
Takes an unsigned byte (1 byte) and packs it as a bytes-object.
Returns string.
r � z int1store requires 0 <= i <= 255�<B��
ValueError� bytearrayr �pack��is r# � int1storer/ N sD � � �1�u� =��C�� =��;�<�<�<��V�[��q�)�)�*�*�*r% c �| � | dk s| dk rt d� � �t t j d| � � � � S )z`
Takes an unsigned short (2 bytes) and packs it as a bytes-object.
Returns string.
r � z"int2store requires 0 <= i <= 65535�<Hr) r- s r# � int2storer3 Y sD � � �1�u� ?��E� � ?��=�>�>�>��V�[��q�)�)�*�*�*r% c � � | dk s| dk rt d� � �t t j d| � � dd� � � S )zb
Takes an unsigned integer (3 bytes) and packs it as a bytes-object.
Returns string.
r �� z%int3store requires 0 <= i <= 16777215r � r) r- s r# � int3storer7 d sO � � �1�u� B��H�� B��@�A�A�A��V�[��q�)�)�!�A�#�.�/�/�/r% c �| � | dk s| dk rt d� � �t t j d| � � � � S )zb
Takes an unsigned integer (4 bytes) and packs it as a bytes-object.
Returns string.
r � �� z'int4store requires 0 <= i <= 4294967295r r) r- s r# � int4storer: o sF � � �1�u� D��J�� D��B�C�C�C��V�[��q�)�)�*�*�*r% c �| � | dk s| dk rt d� � �t t j d| � � � � S )zZ
Takes an unsigned integer (8 bytes) and packs it as string.
Returns string.
r � z!int8store requires 0 <= i <= 2^64r r) r- s r# � int8storer= z sF � � �1�u� >��(�(� >��<�=�=�=��V�[��q�)�)�*�*�*r% c �� � | dk s| dk rt d� � �| dk rt }n1| dk rt }n#| dk rt }n| dk rt }nt
} || � � S )z�
Takes an unsigned integers and packs it as a bytes-object.
This function uses int1store, int2store, int3store,
int4store or int8store depending on the integer value.
returns string.
r r<