https://t.me/RX1948
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/contrib/gis/geoip2/__pycache__/base.cpython-310.pyc
o

��Ih$�@s�ddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
eedd�eed	d
�eedd�d
�ZGdd�de�ZGdd�d�ZdS)�N)�settings)�ValidationError)�validate_ipv46_address)�to_path�)�City�Country�
GEOIP_PATH�
GEOIP_CITYzGeoLite2-City.mmdb�
GEOIP_COUNTRYzGeoLite2-Country.mmdb)r	r
rc@seZdZdS)�GeoIP2ExceptionN)�__name__�
__module__�__qualname__�rr�@/usr/lib/python3/dist-packages/django/contrib/gis/geoip2/base.pyrsrc@s�eZdZdZdZdZdZdZeeeeeef�Z	dZ
dZdZdZ
d*dd	�Zed
d��Zedd
��Zdd�Zdd�Zd+dd�Zdd�Zdd�Zdd�Zdd�Zd,dd�Zd d!�Zd"d#�Zd$d%�Zed&d'��Zed(d)��ZdS)-�GeoIP2rr����Nc	Cs>||jvr	||_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�||_||_
dStd
|��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.rz	GeoIP.dat)�moder
z
GeoIPCity.datz"Could not load a database from %s.rrz(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_typerrr�__init__.s<
�




zGeoIP2.__init__cCs|jp|jS�N)r"r$�r*rrrr&w�zGeoIP2._readercCs|jr|jjS|jjSr4)r"r-r$r.r5rrr�_country_or_city{szGeoIP2._country_or_citycCs|jr
|j��dSdSr4)r&�closer5rrr�__del__�s�zGeoIP2.__del__cCs4|j��}d|j|jf}d|jj||j|jd�S)Nz[v%s.%s]zH<%(cls)s %(version)s _country_file="%(country)s", _city_file="%(city)s">)�cls�versionr-r.)r&r'�binary_format_major_version�binary_format_minor_version�	__class__r
r#r%)r*�metar;rrr�__repr__�s
�zGeoIP2.__repr__FcCs�t|t�stdt|�j��|r|js|jstd��|r&|js&td|j��|r2|js2td|j	��zt
|�W|StyHt�
|�}Y|Sw)z*Check the query and database availability.z)GeoIP query must be a string, not type %sz*Invalid GeoIP country and city data files.z#Invalid GeoIP country data file: %sz Invalid GeoIP city data file: %s)�
isinstancer!�	TypeError�typer
r"r$rr#r%rr�socket�
gethostbyname)r*�queryr-r.�city_or_countryrrr�_check_query�s



��zGeoIP2._check_querycCs|j|dd�}t|j�|��S)z�
        Return a dictionary of city information for the given IP address or
        Fully Qualified Domain Name (FQDN). Some information in the dictionary
        may be undefined (None).
        T)r.)rHrr$r.�r*rF�	enc_queryrrrr.�szGeoIP2.citycC�|j|dd�}|�|�dS)z9Return the country code for the given IP Address or FQDN.T�rG�country_code�rHr-rIrrrrM��zGeoIP2.country_codecCrK)z9Return the country name for the given IP Address or FQDN.TrL�country_namerNrIrrrrP�rOzGeoIP2.country_namecCs|j|dd�}t|�|��S)z�
        Return a dictionary with the country code and name when given an
        IP address or a Fully Qualified Domain Name (FQDN). For example, both
        '24.124.1.80' and 'djangoproject.com' are valid parameters.
        TrL)rHrr7rIrrrr-�szGeoIP2.country��	longitude�latitudecs,|�|���durdSt�fdd�|D��S)Nc3s�|]}�|VqdSr4r)�.0�o��cdictrr�	<genexpr>�s�z GeoIP2.coords.<locals>.<genexpr>)r.�tuple)r*rF�orderingrrVr�coords�s
z
GeoIP2.coordscCs
|�|�S)z@Return a tuple of the (longitude, latitude) for the given query.�r[�r*rFrrr�lon_lat��
zGeoIP2.lon_latcCs|�|d�S)z@Return a tuple of the (latitude, longitude) for the given query.)rSrRr\r]rrr�lat_lon�r6zGeoIP2.lat_loncCs*|�|�}|rddlm}||dd�SdS)z/Return a GEOS Point object for the given query.r)�Pointi�)�sridN)r^�django.contrib.gis.geosra)r*rF�llrarrr�geos�s

zGeoIP2.geoscCs|j��}d|j|jfS)z@Return information about the GeoIP library and databases in use.zGeoIP Library:
	%s.%s
)r&r'r<r=)r*r?rrr�info�s
zGeoIP2.infocCs
t||�Sr4)r)r:�	full_pathr,rrr�open�r_zGeoIP2.open)NrNN)FFF)rQ) r
rr�	MODE_AUTO�
MODE_MMAP_EXT�	MODE_MMAP�	MODE_FILE�MODE_MEMORY�	frozensetrr%r#r$r"r3�propertyr&r7r9r@rHr.rMrPr-r[r^r`rerf�classmethodrhrrrrrs>
I



	


r)rD�geoip2.databaser�django.confr�django.core.exceptionsr�django.core.validatorsr�django.utils._osr�	resourcesrr�getattrr�	Exceptionrrrrrr�<module>s


�

https://t.me/RX1948 - 2025