geolocate.classes.config module — Geolocate 1.3.0 documentation

# geolocate.classes.config module

Configuration parser module.

Programmed by: Dante Signal31

email: dante.signal31@gmail.com

exception `geolocate.classes.config.` `ConfigNotFound`

  Bases: `Exception`

  Launched when config file is not where is supposed to be.

  `__init__`()

class `geolocate.classes.config.` `Configuration`(user_id='', license_key='', download_url='http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz', update_interval=35, local_database_folder='/home/dante/Developments/geolocate/geolocate/local_database/', local_database_name='GeoLite2-City.mmdb', locators_preference=['geoip2_webservice', 'geoip2_local'])

  Bases: `object`

  Class to encapsulate configuration needed to connect to Geolite2 webservices or downloaded local database. This class also validates parameters read from config files to overcome user typos.

  `__init__`(user_id='', license_key='', download_url='http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz', update_interval=35, local_database_folder='/home/dante/Developments/geolocate/geolocate/local_database/', local_database_name='GeoLite2-City.mmdb', locators_preference=['geoip2_webservice', 'geoip2_local'])
  `disabled_locators`

    Locators registered as default one but not enabled in this GeoIPDatabase.

    Returns: | Disabled locators in this GeoIPDatabase.
    Return type: | set

  `download_url`
  `license_key`
  `local_database_folder`
  `local_database_name`
  `local_database_path`
  `locators_preference`

    Returns: | Enabled locators for this GeoIPDatabase ordered by preference.
    Return type: | list

  `reset_locators_preference`()

    Reset locators preference to default order.

    Returns: | None

  `update_interval`
  `user_id`

class `geolocate.classes.config.` `OpenConfigurationToUpdate`

  Bases: `object`

  Context manager to get a configuration file and save it automatically.

  `__init__`()

exception `geolocate.classes.config.` `ParameterNotValid`(provided_value, parameter, message)

  Bases: `Exception`

  Launched when user_id validation fails.

  `__init__`(provided_value, parameter, message)

exception `geolocate.classes.config.` `UnknownLocators`(unknown_locators)

  Bases: `Exception`

  Raised when an still not implemented location is referenced in any operation.

  `__init__`(unknown_locators)

`geolocate.classes.config.` `get_real_path`(CONFIG_FILE)

`geolocate.classes.config.` `load_configuration`()

  Read configuration file and populate with its data a config.Configuration instance.

  Returns: | Configuration instance populated with configuration file data.
  Return type: | config.Configuration

`geolocate.classes.config.` `save_configuration`(configuration)

  Write Configuration object in config file.

  Parameters: | configuration (config.Configuration) – Configuration to be saved.
  Returns: | None