AlkantarClanX12

Your IP : 3.138.37.43


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

�

l��f�"���dZddlZddlmZmZmZmZmZmZddl	Z	ddl	m
Z
mZmZm
Z
mZmZddlZddlZddlZddlmZddlmZmZmZmZmZmZmZmZGd�d��ZdS)	zG
======================
GeoIP2 Database Reader
======================

�N)�Any�cast�List�Optional�Type�Union)�	MODE_AUTO�	MODE_MMAP�
MODE_MMAP_EXT�	MODE_FILE�MODE_MEMORY�MODE_FD)�	IPAddress)�ASN�AnonymousIP�City�ConnectionType�Country�Domain�
Enterprise�ISPc
���eZdZdZdefdedeeededdfd�Z	dd�Z
dd�Zd
ede
fd�Zd
edefd�Zd
edefd�Zd
edefd�Zd
edefd�Zd
edefd�Zd
edefd�Zd
edefd�Zded
edefd�Zdee e
e ee efded
edee
eeffd�Z!dee ee ee ee ee efded
edeeeeeeffd�Z"de#j$j%fd�Z&d d�Z'dS)!�Readera
GeoIP2 database Reader object.

    Instances of this class provide a reader for the GeoIP2 database format.
    IP addresses can be looked up using the ``country`` and ``city`` methods.

    The basic API for this class is the same for every database. First, you
    create a reader object, specifying a file name or file descriptor.
    You then call the method corresponding to the specific database, passing
    it the IP address you want to look up.

    If the request succeeds, the method call will return a model class for the
    method you called. This model in turn contains multiple record classes,
    each of which represents part of the data returned by the database. If the
    database does not contain the requested information, the attributes on the
    record class will have a ``None`` value.

    If the address is not in the database, an
    ``geoip2.errors.AddressNotFoundError`` exception will be thrown. If the
    database is corrupt or invalid, a ``maxminddb.InvalidDatabaseError`` will
    be thrown.
    N�fileish�locales�mode�returnc��|�dg}tj||��|_|j���j|_||_dS)agCreate GeoIP2 Reader.

        :param fileish: The string path to the GeoIP2 database, or an existing
          file descriptor pointing to the database. Note that this latter
          usage is only valid when mode is MODE_FD.
        :param locales: This is list of locale codes. This argument will be
          passed on to record classes to use when their name properties are
          called. The default value is ['en'].

          The order of the locales is significant. When a record class has
          multiple names (country, city, etc.), its name property will return
          the name in the first locale that has one.

          Note that the only locale which is always present in the GeoIP2
          data is "en". If you do not include this locale, the name property
          may end up returning None even when the record has an English name.

          Currently, the valid locale codes are:

          * de -- German
          * en -- English names may still include accented characters if that
            is the accepted spelling in English. In other words, English does
            not mean ASCII.
          * es -- Spanish
          * fr -- French
          * ja -- Japanese
          * pt-BR -- Brazilian Portuguese
          * ru -- Russian
          * zh-CN -- Simplified Chinese.
        :param mode: The mode to open the database with. Valid mode are:
          * MODE_MMAP_EXT - use the C extension with memory map.
          * MODE_MMAP - read from memory map. Pure Python.
          * MODE_FILE - read database as standard file. Pure Python.
          * MODE_MEMORY - load database into memory. Pure Python.
          * MODE_FD - the param passed via fileish is a file descriptor, not a
             path. This mode implies MODE_MEMORY. Pure Python.
          * MODE_AUTO - try MODE_MMAP_EXT, MODE_MMAP, MODE_FILE in that order.
             Default.

        N�en)�	maxminddb�
open_database�
_db_reader�metadata�
database_type�_db_type�_locales)�selfrrrs    �o/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/geoip2/database.py�__init__zReader.__init__=sH��V�?��f�G�#�1�'�4�@�@�����0�0�2�2�@��
���
�
�
�c��|S�N��r's r(�	__enter__zReader.__enter__ns���r*�exc_type�	exc_value�	tracebackc�.�|���dSr,)�close)r'r0r1r2s    r(�__exit__zReader.__exit__qs���
�
�����r*�
ip_addressc�t�tt|�tjjd|����S)z�Get the Country object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.Country` object

        r)rr�
_model_for�geoip2�models�r'r6s  r(�countryzReader.countryts0����T�_�_�V�]�%:�I�z�R�R�
�
�	
r*c�t�tt|�tjjd|����S)z�Get the City object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.City` object

        r)rrr8r9r:r;s  r(�cityzReader.city�s)���D�$�/�/�&�-�*<�f�j�Q�Q�R�R�Rr*c�t�tt|�tjjd|����S)z�Get the AnonymousIP object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.AnonymousIP` object

        zGeoIP2-Anonymous-IP)rr�_flat_model_forr9r:r;s  r(�anonymous_ipzReader.anonymous_ip�s9����� � ��
�)�+@�*�
�
�
�
�	
r*c�t�tt|�tjjd|����S)z�Get the ASN object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.ASN` object

        zGeoLite2-ASN)rrr@r9r:r;s  r(�asnz
Reader.asn�s2�����%�%�f�m�&7���T�T�
�
�	
r*c�t�tt|�tjjd|����S)z�Get the ConnectionType object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.ConnectionType` object

        zGeoIP2-Connection-Type)rrr@r9r:r;s  r(�connection_typezReader.connection_type�s9����� � ��
�,�.F�
�
�
�
�
�	
r*c�t�tt|�tjjd|����S)z�Get the Domain object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.Domain` object

        z
GeoIP2-Domain)rrr@r9r:r;s  r(�domainz
Reader.domain�s3����� � ���!5��
�S�S�
�
�	
r*c�t�tt|�tjjd|����S)z�Get the Enterprise object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.Enterprise` object

        r)rrr8r9r:r;s  r(�
enterprisezReader.enterprise�s1�����O�O�F�M�4�l�J�O�O�
�
�	
r*c�t�tt|�tjjd|����S)z�Get the ISP object for the IP address.

        :param ip_address: IPv4 or IPv6 address as a string.

        :returns: :py:class:`geoip2.models.ISP` object

        z
GeoIP2-ISP)rrr@r9r:r;s  r(�ispz
Reader.isp�s2�����%�%�f�m�&7��z�R�R�
�
�	
r*r$c��||jvr:tj��dd}td|�d|j�d����|j�|��\}}|�#tj�d|�d����||fS)N��zThe z  method cannot be used with the z	 databasezThe address z is not in the database.)	r%�inspect�stack�	TypeErrorr"�get_with_prefix_lenr9�errors�AddressNotFoundError)r'r$r6�caller�record�
prefix_lens      r(�_getzReader._get�s�����
�-�-��]�_�_�Q�'��*�F��W�v�W�W�t�}�W�W�W���
� $��B�B�:�N�N�����>��-�4�4�C�z�C�C�C���
��z�!�!r*�model_class�typesc��|�||��\}}|�di��}||d<||d<|||j���S)N�traitsr6rW)r)rX�
setdefaultr&)r'rYrZr6rVrWr\s       r(r8zReader._model_for�s\�� $�y�y��
�;�;�����"�"�8�R�0�0��)��|��)��|���{�6�4�=�9�9�9�9r*c�^�|�||��\}}||d<||d<||��S)Nr6rW)rX)r'rYrZr6rVrWs      r(r@zReader._flat_model_for�s@�� $�y�y��
�;�;����)��|��)��|���{�6�"�"�"r*c�4�|j���S)zlThe metadata for the open database.

        :returns: :py:class:`maxminddb.reader.Metadata` object
        )r"r#r.s r(r#zReader.metadatas��
��'�'�)�)�)r*c�8�|j���dS)zCloses the GeoIP2 database.N)r"r4r.s r(r4zReader.closes��	
��������r*)rr)r0Nr1Nr2NrN)rN)(�__name__�
__module__�__qualname__�__doc__r	�strrr�intr)r/r5rrr<rr>rrArrCrrErrGrrIrrKrrXrrr8r@r �reader�Metadatar#r4r-r*r(rr&s���������.<@�Y�/ �/ ��/ �%-�d�3�i�%8�/ �GJ�/ �	
�/ �/ �/ �/ �b��������
�)�
��
�
�
�
�S�y�S�T�S�S�S�S�

�y�

�[�

�

�

�

�

�i�

�C�

�

�

�

�

�)�

��

�

�

�

�
��
�v�
�
�
�
�
�Y�
�:�
�
�
�
�

�i�

�C�

�

�

�

�"�#�"�9�"��"�"�"�"�
:��4��=�$�z�*:�D��J�F�G�
:��
:��	
:�

�w�
�D�(�	)�
:�
:�
:�
:�#����L�$�s�)�T�.�%9�4��9�d�;�FW�W�
�#�
�#��
#�
�~�s�K���<�	=�#�#�#�#�*�)�*�3�*�*�*�*� � � � � � r*r)rdrO�typingrrrrrrr r	r
rrr
rr9�
geoip2.models�
geoip2.errors�geoip2.typesrrrrrrrrrrr-r*r(�<module>rms{��������9�9�9�9�9�9�9�9�9�9�9�9�9�9�9�9����������������������
�
�
���������"�"�"�"�"�"�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�e �e �e �e �e �e �e �e �e �e r*