geolocate.classes.config module

Configuration parser module.

Programmed by: Dante Signal31

email: dante.signal31@gmail.com

exception geolocate.classes.config.ConfigNotFound[source]

Bases: Exception

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

__init__()[source]
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'])[source]

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'])[source]
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()[source]

Reset locators preference to default order.

Returns:None
update_interval
user_id
class geolocate.classes.config.OpenConfigurationToUpdate[source]

Bases: object

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

__init__()[source]
exception geolocate.classes.config.ParameterNotValid(provided_value, parameter, message)[source]

Bases: Exception

Launched when user_id validation fails.

__init__(provided_value, parameter, message)[source]
exception geolocate.classes.config.UnknownLocators(unknown_locators)[source]

Bases: Exception

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

__init__(unknown_locators)[source]
geolocate.classes.config.get_real_path(CONFIG_FILE)[source]
geolocate.classes.config.load_configuration()[source]

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)[source]

Write Configuration object in config file.

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