better dynamic support

This commit is contained in:
Emmanuel Garette 2021-01-23 12:06:18 +01:00
parent 7545e6105d
commit 4df2d0e2bf

View file

@ -6,7 +6,7 @@ from .annotator import ERASED_ATTRIBUTES, CONVERT_OPTION
FUNC_TO_DICT = []
ATTRIBUTES_ORDER = ('name', 'doc', 'default', 'multi', 'properties', 'min_number', 'max_number', 'dynamic')
ATTRIBUTES_ORDER = ('name', 'doc', 'default', 'multi', 'properties', 'min_number', 'max_number')
class Root(): # pylint: disable=R0903
@ -453,6 +453,7 @@ class Family(Common):
if not self.option_name:
self.populate_attrib()
self.parse_properties()
self.populate_dynamic()
self.option_name = self.elt.reflector_name
object_name = self.get_object_name()
attrib = self.get_attrib() + \
@ -461,17 +462,16 @@ class Family(Common):
self.populate_informations()
return self.option_name
def populate_dynamic(self):
if hasattr(self.elt, 'dynamic'):
dyn = self.elt.dynamic.reflector_object.get()
self.attrib['suffixes'] = f"Calculation(func.calc_value, Params((ParamOption({dyn}))))"
def populate_attrib(self):
"""parse a populate attributes
"""
for key in self.get_attributes(self.elt):
value = getattr(self.elt, key)
if key == 'dynamic':
dynamic = value.reflector_object.get()
self.attrib['suffixes'] = \
f"Calculation(func.calc_value, Params((ParamOption({dynamic}))))"
else:
self.attrib[key] = value
self.attrib[key] = getattr(self.elt, key)
def parse_properties(self):
"""parse current children