AlkantarClanX12

Your IP : 18.226.187.210


Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/maxminddb/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/maxminddb/__pycache__/decoder.cpython-311.pyc

�

h��f]���dZddlZddlmZmZmZmZmZ	ddlZn
#e	$rdZYnwxYwddl
mZddlm
Z
ddlmZGd�d��ZdS)	zl
maxminddb.decoder
~~~~~~~~~~~~~~~~~

This package contains code for decoding the MaxMind DB data section.

�N)�cast�Dict�List�Tuple�Union��InvalidDatabaseError)�
FileBuffer)�Recordc�r�eZdZdZ		d deedefdededd	fd
�Z	dedede
eeeffd
�Z
dedede
eeffd�Zdedede
eeffd�Zdedede
eeffd�Zdedede
eeffd�Zdedede
eeffd�Zdedede
eeefeffd�Zdedede
eeffd�Zdedede
eeffd�Zdedede
eeffd�Zeeeeeeeeeee
eed�
Zdede
eeffd�Zdede
eeffd�Zedededd	fd���Zdededede
eeffd�Zd	S)!�Decoderz.Decoder for the data section of the MaxMind DBrF�database_bufferz	mmap.mmap�pointer_base�pointer_test�returnNc�0�||_||_||_dS)aCreated a Decoder for a MaxMind DB

        Arguments:
        database_buffer -- an mmap'd MaxMind DB file.
        pointer_base -- the base number to use when decoding a pointer
        pointer_test -- used for internal unit testing of pointer code
        N)�
_pointer_test�_buffer�
_pointer_base)�selfrrrs    �q/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/maxminddb/decoder.py�__init__zDecoder.__init__s!��*���&���)������size�offsetc��g}t|��D]/}|�|��\}}|�|���0||fS�N)�range�decode�append)rrr�array�_�values      r�
_decode_arrayzDecoder._decode_array,sP�����t���	 �	 �A�"�k�k�&�1�1�O�U�F��L�L�������f�}�rc��|dk|fS)Nr�)rrrs   r�_decode_booleanzDecoder._decode_boolean3s���q�y�&� � rc�.�||z}|j||�|fSr)r�rrr�
new_offsets    r�
_decode_byteszDecoder._decode_bytes6s"���d�]�
��|�F�:�-�.�
�:�:rc��|�|d��||z}|j||�}tjd|��\}||fS)N�s!d��_verify_sizer�struct�unpack�rrrr*�packed_bytesr#s      r�_decode_doublezDecoder._decode_double:�P�����$��"�"�"��d�]�
��|�F�:�$5�6���=���5�5����j� � rc��|�|d��||z}|j||�}tjd|��\}||fS)N�s!fr.r2s      r�
_decode_floatzDecoder._decode_floatAr5rc��|dkrd|fS||z}|j||�}|dkr|�dd��}tjd|��\}||fS)Nrr7�s!i)r�rjustr0r1r2s      r�
_decode_int32zDecoder._decode_int32Hsk���1�9�9��f�9���d�]�
��|�F�:�$5�6���1�9�9�'�-�-�a��9�9�L��=���5�5����j� � rc���i}t|��D]J}|�|��\}}|�|��\}}||tt|��<�K||fSr)rrr�str)rrr�	containerr"�keyr#s       r�_decode_mapzDecoder._decode_mapSsf��')�	��t���	.�	.�A� �K�K��/�/�M�S�&�"�k�k�&�1�1�O�U�F�(-�I�d�3��n�n�%�%��&� � rc�f�|dz	dz}|j|||z�}||z}|dkr:t|dzg��|z}tjd|��d|jz}n�|dkr@dt|dzg��z|z}tjd|��dd	z|jz}nf|dkr=t|dzg��|z}tjd|��dd
z|jz}n#tjd|��d|jz}|jr||fS|�|��\}}||fS)N����!Hr�r:�!Iii)r�bytesr0r1rrr)	rrr�pointer_size�bufr*�pointerr#r"s	         r�_decode_pointerzDecoder._decode_pointer[s[����	�Q����l�6�F�\�$9�9�:���l�*�
��1��������%�%��+�C��m�E�3�/�/��2�T�5G�G�G�G�
�Q�
�
��E�4�#�:�,�/�/�/�#�5�C��m�E�3�/�/��2�T�9�D�<N�N�G�G�
�Q�
�
������%�%��+�C��m�E�3�/�/��2�V�;�d�>P�P�G�G��m�E�3�/�/��2�T�5G�G�G���	'��J�&�&��[�[��)�)�
����j� � rc�d�||z}|j||�}t�|d��|fS)N�big)r�int�
from_bytes)rrrr*�
uint_bytess     r�_decode_uintzDecoder._decode_uintrs5���d�]�
��\�&��"3�4�
��~�~�j�%�0�0�*�<�<rc�T�||z}|j||��d��|fS)Nzutf-8)rrr)s    r�_decode_utf8_stringzDecoder._decode_utf8_stringws0���d�]�
��|�F�:�-�.�5�5�g�>�>�
�J�Jr)
rDrGrCr7��rEr-�	�
���c��|dz}|j|}|dz	}|s|�|��\}}	|j|}n&#t$r}t	d|�d���|�d}~wwxYw|�|||��\}}||||��S)z�Decode a section of the data section starting at offset

        Arguments:
        offset -- the location of the data structure to decode
        rDrVzUnexpected type number (z
) encounteredN)r�_read_extended�
_type_decoder�KeyErrorr	�_size_from_ctrl_byte)rrr*�	ctrl_byte�type_num�decoder�exrs        rrzDecoder.decode�s����a�Z�
��L��(�	���>���	E�%)�%8�%8��%D�%D�"�X�z�	��(��2�G�G���	�	�	�&�B�8�B�B�B����
�����	����
"�6�6�y�*�h�W�W���z��w�t�T�:�.�.�.s�
A�
A$�A�A$c�f�|j|}|dz}|dkrtd|�d����||dzfS)NrEz^Something went horribly wrong in the decoder. An extended type resolved to a type number < 8 (�)rD)rr	)rr�	next_bytercs    rr^zDecoder._read_extended�s^���L��(�	��q�=���a�<�<�&�L�@H�L�L�L���
���!��#�#r�expected�actualc�0�||krtd���dS)NzXThe MaxMind DB file's data section contains bad data (unknown data type or corrupt data)r)rirjs  rr/zDecoder._verify_size�s,���v���&�6���
��rrbrcc�P�|dz}|dks|dkr||fS|dkrd|j|z}||dzfS|dkr6|dz}|j||�}dtjd|��dz}||fS|d	z}|j||�}tjd
d|z��ddz}||fS)
N�rD��rGirFrrCrHr:i)rr0r1)rrbrrcrr*�
size_bytess       rrazDecoder._size_from_ctrl_byte�s����4����q�=�=�D�2�I�I���<���2�:�:����V�,�,�D���!��#�#��2�:�:��!��J���f�Z�&7�8�J����u�j�9�9�!�<�<�D���#�#��a�Z�
��\�&��"3�4�
��}�U�G�j�$8�9�9�!�<�u�D���Z��r)rF) �__name__�
__module__�__qualname__�__doc__rr
rIrP�boolrrrrr$r'r+�floatr4r8r<rr>rArMrSrUr_rr^�staticmethodr/rar&rrr
r
so������8�8�
�"�	*�*��z�;��=�>�*��*��	*�

�*�*�*�*�"�#��s��u�T�&�\�3�=N�7O�����!�C�!��!��t�S�y�9I�!�!�!�!�;�#�;�s�;�u�U�C�Z�7H�;�;�;�;�!�3�!��!��e�S�j�8I�!�!�!�!�!�#�!�s�!�u�U�C�Z�7H�!�!�!�!�	!�#�	!�s�	!�u�S�#�X��	!�	!�	!�	!�!��!�S�!�U�4��V��;L�c�;Q�5R�!�!�!�!�!�C�!��!��v�s�{�9K�!�!�!�!�.=��=�c�=�e�C��H�o�=�=�=�=�
K��K�S�K�U�3��8�_�K�K�K�K�
���������������M� /�S�/�U�6�3�;�%7�/�/�/�/�.$�S�$�U�3��8�_�$�$�$�$���s��C��D�����\�� �� �&)� �58� �	�s�C�x�� � � � � � rr
)rtr0�typingrrrrr�mmap�ImportError�maxminddb.errorsr	�maxminddb.filer
�maxminddb.typesrr
r&rr�<module>r~s������
�
�
�1�1�1�1�1�1�1�1�1�1�1�1�1�1���K�K�K�K�������D�D�D�����
2�1�1�1�1�1�%�%�%�%�%�%�"�"�"�"�"�"�r �r �r �r �r �r �r �r �r �r s��%�%