class documentation

class GeoIP2:

View In Hierarchy

Undocumented

Class Method open Undocumented
Constant MODE​_AUTO Undocumented
Constant MODE​_FILE Undocumented
Constant MODE​_MEMORY Undocumented
Constant MODE​_MMAP Undocumented
Constant MODE​_MMAP​_EXT Undocumented
Method __del__ Undocumented
Method __init__ 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.
Method __repr__ Undocumented
Method ​_check​_query Check the query and database availability.
Method city 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).
Method coords Undocumented
Method country 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.
Method country​_code Return the country code for the given IP Address or FQDN.
Method country​_name Return the country name for the given IP Address or FQDN.
Method geos Return a GEOS Point object for the given query.
Method lat​_lon Return a tuple of the (latitude, longitude) for the given query.
Method lon​_lat Return a tuple of the (longitude, latitude) for the given query.
Class Variable cache​_options Undocumented
Instance Variable ​_cache Undocumented
Instance Variable ​_city Undocumented
Instance Variable ​_city​_file Undocumented
Instance Variable ​_country Undocumented
Instance Variable ​_country​_file Undocumented
Property ​_country​_or​_city Undocumented
Property ​_reader Undocumented
Property info Return information about the GeoIP library and databases in use.
@classmethod
def open(cls, full_path, cache):

Undocumented

MODE_AUTO: int =

Undocumented

Value
0
MODE_FILE: int =

Undocumented

Value
4
MODE_MEMORY: int =

Undocumented

Value
8
MODE_MMAP: int =

Undocumented

Value
2
MODE_MMAP_EXT: int =

Undocumented

Value
1
def __del__(self):

Undocumented

def __init__(self, path=None, cache=0, country=None, city=None):

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.
  • 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.
  • city: The name of the GeoIP city data file. Defaults to
    'GeoLite2-City.mmdb'; overrides the GEOIP_CITY setting.
def __repr__(self):

Undocumented

def _check_query(self, query, country=False, city=False, city_or_country=False):
Check the query and database availability.
def city(self, query):
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).
def coords(self, query, ordering=('longitude', 'latitude')):

Undocumented

def country(self, query):
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.
def country_code(self, query):
Return the country code for the given IP Address or FQDN.
def country_name(self, query):
Return the country name for the given IP Address or FQDN.
def geos(self, query):
Return a GEOS Point object for the given query.
def lat_lon(self, query):
Return a tuple of the (latitude, longitude) for the given query.
def lon_lat(self, query):
Return a tuple of the (longitude, latitude) for the given query.
cache_options =

Undocumented

_cache =

Undocumented

_city =

Undocumented

_city_file =

Undocumented

_country =

Undocumented

_country_file =

Undocumented

@property
_country_or_city =

Undocumented

@property
_reader =

Undocumented

@property
info =
Return information about the GeoIP library and databases in use.