accept module properties without leading '.' in config files
as module properties and parameters anyway share the same namespace, there is no need to distinguish in config files. + a parameter default value may be overriden just with a class attribute. Both improvements help to switch between parameters and properties more easily. Change-Id: Ieb5cf3121f37c7c04e63345d3e95dfaf42726455 Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/22054 Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
@ -100,6 +100,7 @@ class Module(HasProperties, metaclass=ModuleMeta):
|
||||
|
||||
# 2) check and apply properties specified in cfgdict
|
||||
# specified as '.<propertyname> = <propertyvalue>'
|
||||
# (this is for legacy config files only)
|
||||
for k, v in list(cfgdict.items()): # keep list() as dict may change during iter
|
||||
if k[0] == '.':
|
||||
if k[1:] in self.__class__.properties:
|
||||
@ -108,6 +109,12 @@ class Module(HasProperties, metaclass=ModuleMeta):
|
||||
raise ConfigError('Module %r has no property %r' %
|
||||
(self.name, k[1:]))
|
||||
|
||||
# 3) check and apply properties specified in cfgdict as
|
||||
# '<propertyname> = <propertyvalue>' (without '.' prefix)
|
||||
for k in self.__class__.properties:
|
||||
if k in cfgdict:
|
||||
self.setProperty(k, cfgdict.pop(k))
|
||||
|
||||
# 4) set automatic properties
|
||||
mycls = self.__class__
|
||||
myclassname = '%s.%s' % (mycls.__module__, mycls.__name__)
|
||||
@ -175,7 +182,8 @@ class Module(HasProperties, metaclass=ModuleMeta):
|
||||
raise ConfigError(
|
||||
'Module %s:config Parameter %r '
|
||||
'not understood! (use one of %s)' %
|
||||
(self.name, k, ', '.join(self.parameters.keys())))
|
||||
(self.name, k, ', '.join(list(self.parameters) +
|
||||
list(self.__class__.properties))))
|
||||
|
||||
# 4) complain if a Parameter entry has no default value and
|
||||
# is not specified in cfgdict and deal with parameters to be written.
|
||||
|
Reference in New Issue
Block a user