aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/config/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman_pgp/config/config.py')
-rw-r--r--src/mailman_pgp/config/config.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/mailman_pgp/config/config.py b/src/mailman_pgp/config/config.py
index 7999e65..0b5fe4f 100644
--- a/src/mailman_pgp/config/config.py
+++ b/src/mailman_pgp/config/config.py
@@ -31,6 +31,15 @@ from mailman_pgp.config.validator import ConfigValidator
class Config(ConfigParser):
"""A ConfigParser with a name."""
+ def __init__(self):
+ super().__init__()
+ self.name = None
+ self.dict = None
+ schema = resource_string('mailman_pgp.config',
+ 'schema.cfg').decode('utf-8')
+ self.validator = ConfigValidator(schema)
+ self.converter = ConfigConverter(schema)
+
def load(self, name):
"""
Load the plugin configuration, and set our name.
@@ -43,19 +52,15 @@ class Config(ConfigParser):
dict(mailman_config.plugin_configs)[self.name].configuration))
def validate(self):
- """
-
- """
- validator = ConfigValidator(
- resource_string('mailman_pgp.config',
- 'schema.cfg').decode('utf-8'))
- validator.validate(self)
+ self.validator.validate(self)
def convert(self):
- """
+ self.dict = self.converter.convert(self)
- """
- converter = ConfigConverter(
- resource_string('mailman_pgp.config',
- 'schema.cfg').decode('utf-8'))
- converter.convert(self)
+ def get_value(self, section, option):
+ return self.dict[section][option]
+
+ def set(self, section, option, value=None):
+ self.dict[section][option] = self.converter.converter(section, option)(
+ value)
+ return super().set(section, option, value)