fix: valid mode if no mode defined
This commit is contained in:
parent
086667d7a4
commit
cdb62e5509
1 changed files with 22 additions and 7 deletions
|
@ -66,7 +66,7 @@ class Annotator(Walk):
|
|||
return
|
||||
self.check_leadership()
|
||||
self.remove_empty_families()
|
||||
self.family_names()
|
||||
self.family_description()
|
||||
if self.objectspace.modes_level:
|
||||
self.modes = {
|
||||
name: Mode(idx)
|
||||
|
@ -75,6 +75,11 @@ class Annotator(Walk):
|
|||
self.default_variable_mode = self.objectspace.default_variable_mode
|
||||
self.default_family_mode = self.objectspace.default_family_mode
|
||||
self.change_modes()
|
||||
else:
|
||||
for family in self.get_families():
|
||||
self.valid_mode(family)
|
||||
for variable in self.get_variables():
|
||||
self.valid_mode(variable)
|
||||
self.convert_help()
|
||||
|
||||
def check_leadership(self) -> None:
|
||||
|
@ -113,11 +118,15 @@ class Annotator(Walk):
|
|||
return True
|
||||
return False
|
||||
|
||||
def family_names(self) -> None:
|
||||
"""Set doc, path, ... to family"""
|
||||
def family_description(self) -> None:
|
||||
for family in self.get_families():
|
||||
if not family.description:
|
||||
family.description = family.name
|
||||
if family.type == 'dynamic' and isinstance(family.dynamic, VariableCalculation):
|
||||
path = self.objectspace.paths.get_full_path(family.dynamic.variable,
|
||||
family.path,
|
||||
)
|
||||
self.objectspace.informations.add(family.path, "dynamic_variable", path)
|
||||
|
||||
def change_modes(self):
|
||||
"""change the mode of variables"""
|
||||
|
@ -159,10 +168,16 @@ class Annotator(Walk):
|
|||
) -> None:
|
||||
modes_level = self.objectspace.modes_level
|
||||
if self._has_mode(obj) and obj.mode not in modes_level:
|
||||
msg = _(
|
||||
f'mode "{obj.mode}" for "{obj.name}" is not a valid mode, '
|
||||
f"valid modes are {modes_level}"
|
||||
)
|
||||
if modes_level:
|
||||
msg = _(
|
||||
f'mode "{obj.mode}" for "{obj.name}" is not a valid mode, '
|
||||
f"valid modes are {modes_level}"
|
||||
)
|
||||
else:
|
||||
msg = _(
|
||||
f'mode "{obj.mode}" for "{obj.name}" is not a valid mode, '
|
||||
f"no modes are available"
|
||||
)
|
||||
raise DictConsistencyError(msg, 71, obj.xmlfiles)
|
||||
|
||||
def _set_default_mode(
|
||||
|
|
Loading…
Reference in a new issue