diff options
| author | J08nY | 2017-08-01 00:55:11 +0200 |
|---|---|---|
| committer | J08nY | 2017-08-01 00:55:11 +0200 |
| commit | 89e7005f70a7feda03f15cbe39bf866a6f5bd059 (patch) | |
| tree | a5d61f909810688d32fda0ba10ce422eccbb5be5 /src/mailman_pgp/config/config.py | |
| parent | cce2409e111c4b29bb8739c0699885007e7b81a2 (diff) | |
| download | mailman-pgp-89e7005f70a7feda03f15cbe39bf866a6f5bd059.tar.gz mailman-pgp-89e7005f70a7feda03f15cbe39bf866a6f5bd059.tar.zst mailman-pgp-89e7005f70a7feda03f15cbe39bf866a6f5bd059.zip | |
Diffstat (limited to 'src/mailman_pgp/config/config.py')
| -rw-r--r-- | src/mailman_pgp/config/config.py | 31 |
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) |
