File: //opt/imunify360/venv/lib64/python3.11/site-packages/geoip2/__pycache__/database.cpython-311.pyc
�
ᐣ8��� � � d Z ddlZddlmZmZmZmZmZmZ ddl Z ddl m
Z
mZmZm
Z
mZmZ ddlZddlZddlZddlmZ ddlmZmZmZmZmZmZmZmZ G d� 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
�� � e Zd ZdZdefdedeee deddfd�Z dd�Z
dd�Zd
ede
fd�Zd
edefd�Zd
edefd�Zd
edefd�Zd
edefd�Zd
edefd�Zd
edefd�Zd
edefd�Zded
edefd�Zdee e
e e e e f ded
edee
eef fd�Z!dee e e e e e e e e e f ded
edeeeeeef fd�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}t j ||� � | _ | j � � � j | _ || _ dS )ag Create 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)�selfr r r s ��/srv/buildsys-work-dir/castor/build_node/builder-0/TMJYY/unpkd_srcs/imunify360-venv-2.6.0/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'