diff options
author | Ruben Pollan <meskio@sindominio.net> | 2017-08-31 10:57:41 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2017-08-31 12:56:44 +0200 |
commit | f721c5ef0cdd9952d014a1dc9e3a944afc0f7f45 (patch) | |
tree | 990b0a2f03b2a71426e197ad64909f911143001f /src/leap/bitmask/config.py | |
parent | 0db7a322a103b9886e74d9e017aa4a6298fdbe55 (diff) |
[feat] add the posibility of extracting a section of the config
So each service can have it's own config section passed to the
constructor.
Diffstat (limited to 'src/leap/bitmask/config.py')
-rw-r--r-- | src/leap/bitmask/config.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/leap/bitmask/config.py b/src/leap/bitmask/config.py index 833980d..4c1fbca 100644 --- a/src/leap/bitmask/config.py +++ b/src/leap/bitmask/config.py @@ -67,6 +67,9 @@ class Configuration(object): self.read() assert self.config.get(section, option) == value + def get_section(self, section): + return _ConfigurationSection(self, section) + def read(self): self.config = ConfigParser.SafeConfigParser() if not os.path.isfile(self.config_path): @@ -82,3 +85,15 @@ class Configuration(object): def _create_default_config(self): with open(self.config_path, 'w') as outf: outf.write(self.default_config) + + +class _ConfigurationSection(object): + def __init__(self, config, section): + self.config = config + self.section = section + + def get(self, option, default=None, boolean=False): + return self.config.get(self.section, option, default, boolean) + + def set(self, option, value): + return self.config.set(self.section, option, value) |