user friendly reporting of config errors
Config errors are collected first, and raised after processing all modules. This is more user friendly. + remove redundant check for predefined accessibles in modules.py + fixed error handling for exporting parameters in params.py + fixed handling of bare attributes overwriting properties Change-Id: I894bda291ab85ccec3d771c4903393c808af0a2a
This commit is contained in:
@ -158,7 +158,7 @@ class HasProperties(HasDescriptors):
|
||||
cls.propertyDict = properties
|
||||
# treat overriding properties with bare values
|
||||
for pn, po in properties.items():
|
||||
value = cls.__dict__.get(pn, po)
|
||||
value = getattr(cls, pn, po)
|
||||
if not isinstance(value, Property): # attribute is a bare value
|
||||
po = Property(**po.__dict__)
|
||||
try:
|
||||
@ -177,11 +177,11 @@ class HasProperties(HasDescriptors):
|
||||
"""validates properties and checks for min... <= max..."""
|
||||
for pn, po in self.propertyDict.items():
|
||||
if po.mandatory:
|
||||
if pn not in self.propertyDict:
|
||||
try:
|
||||
self.propertyValues[pn] = po.datatype(self.propertyValues[pn])
|
||||
except (KeyError, BadValueError) as e:
|
||||
name = getattr(self, 'name', self.__class__.__name__)
|
||||
raise ConfigError('Property %r of %s needs a value of type %r!' % (pn, name, po.datatype))
|
||||
# apply validator (which may complain further)
|
||||
self.propertyValues[pn] = po.datatype(self.propertyValues[pn])
|
||||
raise ConfigError('%s.%s needs a value of type %r!' % (name, pn, po.datatype))
|
||||
for pn, po in self.propertyDict.items():
|
||||
if pn.startswith('min'):
|
||||
maxname = 'max' + pn[3:]
|
||||
|
Reference in New Issue
Block a user