ConfigurableObject: add set_default() / set_defaults() methods
This commit is contained in:
parent
e71fb28295
commit
93b06d6127
1 changed files with 10 additions and 0 deletions
|
@ -1156,6 +1156,16 @@ class ConfigurableObject:
|
|||
|
||||
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):
|
||||
"""Configure options on registered mylib.Config object"""
|
||||
assert self._config, (
|
||||
|
|
Loading…
Reference in a new issue