geolocate.classes.geowrapper module — Geolocate 1.3.0 documentation

# geolocate.classes.geowrapper module

geolocate wrapper to Geolite2 API.

Programmed by: Dante Signal31

email: dante.signal31@gmail.com

exception `geolocate.classes.geowrapper.` `CompressedFileNotFound`(compressed_database_path)

  Bases: `OSError`

  Raised when no .gz compressed file is found in temporary folder where downloaded data is placed.

  `__init__`(compressed_database_path)

exception `geolocate.classes.geowrapper.` `GeoIP2WebServiceNotConfigured`

  Bases: `Exception`

  GeoIP2 WebService access is still not configured.

  `__init__`()

class `geolocate.classes.geowrapper.` `GeoIPDatabase`(configuration)

  Bases: `object`

  Location engines may have multiple query methods. This class encapsulates them all in _locators list.

  `__init__`(configuration)

    Parameters: | configuration (config.Configuration) – Geolocate configuration.

  `geoip2_local`
  `geoip2_webservice`

    Returns: | GeoIPLocateor to query GeoIP webservice.
    Return type: | WebServiceGeoLocator
    Raises: | GeoIP2WebServiceNotConfigured

  `locate`(ip)

    Query enabled locators in preference order until getting any geodata.

    Parameters: | ip (IP address string.) – IP address to look for.
    Returns: | Location data for that address.
    Return type: | geoip2.models.City

class `geolocate.classes.geowrapper.` `GeoLocator`(configuration)

  Bases: `object`

  `__init__`(configuration)
  `locate`(ip)

    Get geolocation data from database.

    Parameters: | ip (str) – IP address we are asking about.
    Raises: | geoip2.errors.AddressNotFoundError
    Returns: | Geolocation data.
    Return type: | geoip2.models.City

exception `geolocate.classes.geowrapper.` `InvalidLocalDatabase`(local_database_path)

  Bases: `Exception`

  Local database exists but is corrupted.

  `__init__`(local_database_path)

class `geolocate.classes.geowrapper.` `LocalDatabaseGeoLocator`(configuration)

  Bases: `geolocate.classes.geowrapper.GeoLocator`

  `__init__`(configuration)

    Parameters: | configuration (config.Configuration) – Geolocate configuration.
    Returns: | none
    Raise: | LocalDatabaseNotFound
    Raise: | InvalidLocalDatabase

exception `geolocate.classes.geowrapper.` `LocalDatabaseNotFound`(local_database_path)

  Bases: `OSError`

  Local database file is missing.

  `__init__`(local_database_path)

exception `geolocate.classes.geowrapper.` `NotValidDatabaseFileFound`(decompressed_database_path)

  Bases: `OSError`

  Raised when a new database pack is downloaded on local, but after decompression no valid database file is found in decompressed folder.

  `__init__`(decompressed_database_path)

class `geolocate.classes.geowrapper.` `WebServiceGeoLocator`(configuration)

  Bases: `geolocate.classes.geowrapper.GeoLocator`

  `__init__`(configuration)

    Parameters: | configuration (config.Configuration) – Geolocate configuration.
    Returns: | None

`geolocate.classes.geowrapper.` `load_geoip_database`(configuration=None)