Compare commits
No commits in common. "d75a61b4e8563299cd43a36c358953605bfa6746" and "e71fb2829546eb53c96b87abec0580e87aae7ff7" have entirely different histories.
d75a61b4e8
...
e71fb28295
3 changed files with 3 additions and 13 deletions
|
@ -1156,16 +1156,6 @@ class ConfigurableObject:
|
||||||
|
|
||||||
return default if default is not None else self._defaults.get(option)
|
return default if default is not None else self._defaults.get(option)
|
||||||
|
|
||||||
def set_default(self, option, default_value):
|
|
||||||
"""Set option default value"""
|
|
||||||
assert option in self._defaults, f"Unkown option {option}"
|
|
||||||
self._defaults[option] = default_value
|
|
||||||
|
|
||||||
def set_defaults(self, **default_values):
|
|
||||||
"""Set options default value"""
|
|
||||||
for option, default_value in default_values.items():
|
|
||||||
self.set_default(option, default_value)
|
|
||||||
|
|
||||||
def configure(self, comment=None, **kwargs):
|
def configure(self, comment=None, **kwargs):
|
||||||
"""Configure options on registered mylib.Config object"""
|
"""Configure options on registered mylib.Config object"""
|
||||||
assert self._config, (
|
assert self._config, (
|
||||||
|
|
|
@ -143,7 +143,6 @@ class EmailClient(
|
||||||
section.add_option(
|
section.add_option(
|
||||||
StringOption,
|
StringOption,
|
||||||
"templates_path",
|
"templates_path",
|
||||||
default=self._defaults["templates_path"],
|
|
||||||
comment="Path to templates directory",
|
comment="Path to templates directory",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,12 @@ def main(argv=None): # pylint: disable=too-many-locals,too-many-statements
|
||||||
config = Config(__doc__, __name__.replace(".", "_"))
|
config = Config(__doc__, __name__.replace(".", "_"))
|
||||||
|
|
||||||
email_client = EmailClient(config=config)
|
email_client = EmailClient(config=config)
|
||||||
email_client.set_default(
|
email_client.configure()
|
||||||
|
config.set_default(
|
||||||
|
"email",
|
||||||
"templates_path",
|
"templates_path",
|
||||||
os.path.join(os.path.dirname(os.path.realpath(__file__)), "email_templates"),
|
os.path.join(os.path.dirname(os.path.realpath(__file__)), "email_templates"),
|
||||||
)
|
)
|
||||||
email_client.configure()
|
|
||||||
|
|
||||||
# Options parser
|
# Options parser
|
||||||
parser = config.get_arguments_parser(description=__doc__)
|
parser = config.get_arguments_parser(description=__doc__)
|
||||||
|
|
Loading…
Reference in a new issue