Allow passing new default values to Boxes.addSettingsArgs()
This commit is contained in:
parent
6d39db75e1
commit
fd3a333cb0
|
@ -294,9 +294,9 @@ class Boxes:
|
||||||
else:
|
else:
|
||||||
raise ValueError("No default for argument", arg)
|
raise ValueError("No default for argument", arg)
|
||||||
|
|
||||||
def addSettingsArgs(self, settings, prefix=None):
|
def addSettingsArgs(self, settings, prefix=None, **defaults):
|
||||||
prefix = prefix or settings.__name__[:-len("Settings")]
|
prefix = prefix or settings.__name__[:-len("Settings")]
|
||||||
settings.parserArguments(self.argparser, prefix)
|
settings.parserArguments(self.argparser, prefix, **defaults)
|
||||||
self.edgesettings[prefix] = {}
|
self.edgesettings[prefix] = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ class Settings(object):
|
||||||
relative_params = {}
|
relative_params = {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parserArguments(cls, parser, prefix=None):
|
def parserArguments(cls, parser, prefix=None, **defaults):
|
||||||
prefix = prefix or cls.__name__[:-len("Settings")]
|
prefix = prefix or cls.__name__[:-len("Settings")]
|
||||||
|
|
||||||
lines = cls.__doc__.split("\n")
|
lines = cls.__doc__.split("\n")
|
||||||
|
@ -146,6 +146,8 @@ class Settings(object):
|
||||||
group.prefix = prefix
|
group.prefix = prefix
|
||||||
for name, default in (sorted(cls.absolute_params.items()) +
|
for name, default in (sorted(cls.absolute_params.items()) +
|
||||||
sorted(cls.relative_params.items())):
|
sorted(cls.relative_params.items())):
|
||||||
|
if name in defaults:
|
||||||
|
default = defaults[name]
|
||||||
group.add_argument("--%s_%s" % (prefix, name),
|
group.add_argument("--%s_%s" % (prefix, name),
|
||||||
type=type(default),
|
type=type(default),
|
||||||
action="store", default=default,
|
action="store", default=default,
|
||||||
|
|
Loading…
Reference in New Issue