Server : Apache System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64 User : dh_edsupp ( 6597262) PHP Version : 8.2.26 Disable Function : NONE Directory : /lib/python3/dist-packages/django/contrib/gis/geoip2/__pycache__/ |
Upload File : |
o ��Ih$ � @ s� d dl Z d dlZd dlmZ d dlmZ d dlmZ d dl m Z ddlmZm Z eedd�eed d �eedd�d �ZG dd� de�ZG dd� d�ZdS )� N)�settings)�ValidationError)�validate_ipv46_address)�to_path� )�City�Country� GEOIP_PATH� GEOIP_CITYzGeoLite2-City.mmdb� GEOIP_COUNTRYzGeoLite2-Country.mmdb)r r r c @ s e Zd ZdS )�GeoIP2ExceptionN)�__name__� __module__�__qualname__� r r �@/usr/lib/python3/dist-packages/django/contrib/gis/geoip2/base.pyr s r c @ s� e Zd ZdZdZdZdZdZeeeeeef�Z dZ dZdZdZ d*dd �Zed d� �Zedd � �Zdd� Zdd� Zd+dd�Zdd� Zdd� Zdd� Zdd� Zd,dd�Zd d!� Zd"d#� Zd$d%� Zed&d'� �Zed(d)� �ZdS )-�GeoIP2r r � � � � Nc C s> || j v r || _ntd| ��|pt�dd�}|std��t|�}|�� rh||p-t�dd� }|�� rAtj j t|�|d�| _|| _ ||pIt�dd � }|�� r]tj j t|�|d�| _|| _| jsftd | ��dS |�� r�tj j t|�|d�}|�� j}|�d�r�|| _|| _dS |�d�r�|| _|| _ dS td | ��td��)a� Initialize the GeoIP object. No parameters are required to use default settings. Keyword arguments may be passed in to customize the locations of the GeoIP datasets. * path: Base directory to where GeoIP data is located or the full path to where the city or country data files (*.mmdb) are located. Assumes that both the city and country data sets are located in this directory; overrides the GEOIP_PATH setting. If neither is set, defaults to '/usr/share/GeoIP'. * cache: The cache settings when opening up the GeoIP datasets. May be an integer in (0, 1, 2, 4, 8) corresponding to the MODE_AUTO, MODE_MMAP_EXT, MODE_MMAP, MODE_FILE, and MODE_MEMORY, `GeoIPOptions` C API settings, respectively. Defaults to 0, meaning MODE_AUTO. * country: The name of the GeoIP country data file. Defaults to 'GeoLite2-Country.mmdb'; overrides the GEOIP_COUNTRY setting. If neither is set, defaults to 'GeoIP.dat'. * city: The name of the GeoIP city data file. Defaults to 'GeoLite2-City.mmdb'; overrides the GEOIP_CITY setting. If neither is set, defaults to 'GeoIPCity.dat'. z Invalid GeoIP caching option: %sr z/usr/share/GeoIPzDGeoIP path must be provided via parameter or the GEOIP_PATH setting.r z GeoIP.dat)�moder z GeoIPCity.datz"Could not load a database from %s.r r z(Unable to recognize database edition: %sz-GeoIP path must be a valid file or directory.N)� cache_options�_cacher �GEOIP_SETTINGS�getr �is_dir�is_file�geoip2�database�Reader�str�_country� _country_file�_city� _city_file�_reader�metadata� database_type�endswith) �self�path�cache�country�city� country_db�city_db�reader�db_typer r r �__init__. s<