This commit is contained in:
Emmanuel Garette 2021-01-23 21:21:45 +01:00
parent f5c7220930
commit 1d33414e6a
4 changed files with 21 additions and 10 deletions

View file

@ -1,7 +1,7 @@
"""Annotate dictionaries """Annotate dictionaries
""" """
from .group import GroupAnnotator from .group import GroupAnnotator
from .service import ServiceAnnotator, ERASED_ATTRIBUTES from .service import ServiceAnnotator
from .variable import VariableAnnotator, CONVERT_OPTION from .variable import VariableAnnotator, CONVERT_OPTION
from .check import CheckAnnotator from .check import CheckAnnotator
from .value import ValueAnnotator from .value import ValueAnnotator
@ -30,4 +30,4 @@ class SpaceAnnotator: # pylint: disable=R0903
ValueAnnotator(objectspace) ValueAnnotator(objectspace)
__all__ = ('SpaceAnnotator', 'ERASED_ATTRIBUTES', 'CONVERT_OPTION', 'modes') __all__ = ('SpaceAnnotator', 'CONVERT_OPTION', 'modes')

View file

@ -46,6 +46,8 @@ class FamilyAnnotator:
self.convert_help() self.convert_help()
def family_names(self) -> None: def family_names(self) -> None:
"""Set doc, path, ... to family
"""
for families in self.objectspace.space.variables.values(): for families in self.objectspace.space.variables.values():
families.doc = families.name families.doc = families.name
families.path = families.name families.path = families.name

View file

@ -1,5 +1,8 @@
class ValueAnnotator: """Annotate value
"""Annotate check """
class ValueAnnotator: # pylint: disable=R0903
"""Annotate value
""" """
def __init__(self, def __init__(self,
objectspace, objectspace,
@ -10,6 +13,8 @@ class ValueAnnotator:
self.convert_value() self.convert_value()
def convert_value(self) -> None: def convert_value(self) -> None:
"""convert value
"""
for families in self.objectspace.space.variables.values(): for families in self.objectspace.space.variables.values():
for family in families.family.values(): for family in families.family.values():
for variable in family.variable.values(): for variable in family.variable.values():
@ -23,8 +28,8 @@ class ValueAnnotator:
else: else:
self._convert_value(variable) self._convert_value(variable)
def _convert_value(self, @staticmethod
variable, def _convert_value(variable,
variable_type: str=None, variable_type: str=None,
) -> None: ) -> None:
if not hasattr(variable, 'value'): if not hasattr(variable, 'value'):

View file

@ -2,12 +2,14 @@
flattened XML specific flattened XML specific
""" """
from .config import Config from .config import Config
from .annotator import ERASED_ATTRIBUTES, CONVERT_OPTION from .annotator import CONVERT_OPTION
from .objspace import RootRougailObject from .objspace import RootRougailObject
FUNC_TO_DICT = [] FUNC_TO_DICT = []
ATTRIBUTES_ORDER = ('name', 'doc', 'default', 'values', 'multi', 'default_multi', 'properties', 'validators', 'min_number', 'max_number') ATTRIBUTES_ORDER = ('name', 'doc', 'default', 'values', 'multi', 'default_multi', 'properties',
'validators', 'min_number', 'max_number',
)
class Root(): # pylint: disable=R0903 class Root(): # pylint: disable=R0903
@ -159,7 +161,8 @@ class Common:
self.text = text self.text = text
self.elt.reflector_object = self self.elt.reflector_object = self
def populate_properties(self, child): @staticmethod
def populate_properties(child) -> str:
"""Populate properties """Populate properties
""" """
assert child.type == 'calculation' assert child.type == 'calculation'
@ -193,7 +196,8 @@ class Common:
if key == 'properties': if key == 'properties':
value = self.properties_to_string() value = self.properties_to_string()
elif key == 'validators': elif key == 'validators':
value = '[' + ', '.join([self.calculation_value(val, ['ParamSelfOption()']) for val in value]) + ']' value = '[' + ', '.join([self.calculation_value(val, ['ParamSelfOption()']) \
for val in value]) + ']'
elif key == 'values': elif key == 'values':
if value[0].type == 'calculation': if value[0].type == 'calculation':
value = value[0].name.reflector_object.get() value = value[0].name.reflector_object.get()