documentation + fallback on condition
This commit is contained in:
@ -52,7 +52,7 @@ class ConditionAnnotator(TargetAnnotator, ParamAnnotator, Walk):
|
||||
self.target_is_uniq = False
|
||||
self.only_variable = False
|
||||
self.convert_target(self.objectspace.space.constraints.condition)
|
||||
self.check_condition_fallback()
|
||||
self.check_condition_optional()
|
||||
self.convert_condition_source()
|
||||
self.convert_param(self.objectspace.space.constraints.condition)
|
||||
self.check_source_target()
|
||||
@ -106,19 +106,18 @@ class ConditionAnnotator(TargetAnnotator, ParamAnnotator, Walk):
|
||||
f'{condition.source.path}')
|
||||
raise DictConsistencyError(msg, 11, condition.xmlfiles)
|
||||
|
||||
def check_condition_fallback(self):
|
||||
"""a condition with a fallback **and** the source variable doesn't exist
|
||||
def check_condition_optional(self):
|
||||
"""a condition with a optional **and** the source variable doesn't exist
|
||||
"""
|
||||
remove_conditions = []
|
||||
for idx, condition in enumerate(self.objectspace.space.constraints.condition):
|
||||
# fallback
|
||||
if condition.fallback is False or \
|
||||
if condition.optional is False or \
|
||||
self.objectspace.paths.path_is_defined(condition.source):
|
||||
continue
|
||||
if condition.name in ['disabled_if_in', 'mandatory_if_in', 'hidden_if_in']:
|
||||
apply_action = not condition.force_condition_on_fallback
|
||||
if hasattr(condition, 'apply_on_fallback'):
|
||||
apply_action = condition.apply_on_fallback
|
||||
else:
|
||||
apply_action = condition.force_inverse_condition_on_fallback
|
||||
apply_on_fallback = condition.name.endswith('_if_in'):
|
||||
remove_conditions.append(idx)
|
||||
if apply_action:
|
||||
self.force_actions_to_variable(condition)
|
||||
|
@ -32,7 +32,7 @@ from ..utils import normalize_family
|
||||
from ..error import DictConsistencyError
|
||||
# a CreoleObjSpace's attribute has some annotations
|
||||
# that shall not be present in the exported (flatened) XML
|
||||
ERASED_ATTRIBUTES = ('redefine', 'exists', 'fallback', 'optional', 'remove_check', 'namespace',
|
||||
ERASED_ATTRIBUTES = ('redefine', 'exists', 'optional', 'remove_check', 'namespace',
|
||||
'remove_condition', 'path', 'instance_mode', 'index',
|
||||
'level', 'remove_fill', 'xmlfiles', 'type', 'reflector_name',
|
||||
'reflector_object',)
|
||||
|
@ -197,15 +197,11 @@ class VariableAnnotator(Walk): # pylint: disable=R0903
|
||||
"""Convert variable tests value
|
||||
"""
|
||||
for variable in self.get_variables():
|
||||
self._convert_test(variable)
|
||||
|
||||
def _convert_test(self,
|
||||
variable,
|
||||
) -> None:
|
||||
if not hasattr(variable, 'information'):
|
||||
variable.information = self.objectspace.information(variable.xmlfiles)
|
||||
if hasattr(variable, 'test'):
|
||||
if not hasattr(variable, 'test'):
|
||||
continue
|
||||
if variable.test:
|
||||
if not hasattr(variable, 'information'):
|
||||
variable.information = self.objectspace.information(variable.xmlfiles)
|
||||
values = variable.test.split('|')
|
||||
new_values = []
|
||||
for value in values:
|
||||
@ -221,6 +217,8 @@ class VariableAnnotator(Walk): # pylint: disable=R0903
|
||||
"""Convert variable help
|
||||
"""
|
||||
for variable in self.get_variables():
|
||||
if not hasattr(variable, 'information'):
|
||||
variable.information = self.objectspace.information(variable.xmlfiles)
|
||||
self._convert_help(variable)
|
||||
|
||||
@staticmethod
|
||||
|
@ -121,9 +121,8 @@
|
||||
<!ELEMENT condition ((target|param)+)>
|
||||
<!ATTLIST condition name (disabled_if_in|disabled_if_not_in|hidden_if_in|hidden_if_not_in|mandatory_if_in|mandatory_if_not_in) #REQUIRED>
|
||||
<!ATTLIST condition source CDATA #REQUIRED>
|
||||
<!ATTLIST condition fallback (True|False) "False">
|
||||
<!ATTLIST condition force_condition_on_fallback (True|False) "False">
|
||||
<!ATTLIST condition force_inverse_condition_on_fallback (True|False) "False">
|
||||
<!ATTLIST condition optional (True|False) "False">
|
||||
<!ATTLIST condition apply_on_fallback (True|False) #IMPLIED>
|
||||
|
||||
<!ELEMENT param (#PCDATA)>
|
||||
<!ATTLIST param type (string|number|nil|boolean|variable|information|suffix) "string">
|
||||
|
Reference in New Issue
Block a user