This commit is contained in:
Emmanuel Garette 2020-07-06 21:35:25 +02:00
parent 38c95ea87a
commit eb6b22e5b1
21 changed files with 85 additions and 83 deletions

View File

@ -299,18 +299,14 @@ class SpaceAnnotator(object):
self.objectspace = objectspace self.objectspace = objectspace
self.valid_enums = {} self.valid_enums = {}
self.force_value = {} self.force_value = {}
self.has_calc = []
self.force_no_value = []
self.force_not_mandatory = [] self.force_not_mandatory = []
if eosfunc_file: if eosfunc_file:
self.eosfunc = imp.load_source('eosfunc', eosfunc_file) self.eosfunc = imp.load_source('eosfunc', eosfunc_file)
else: else:
self.eosfunc = None self.eosfunc = None
if HIGH_COMPATIBILITY: if HIGH_COMPATIBILITY:
self.default_has_no_value = []
self.has_frozen_if_in_condition = [] self.has_frozen_if_in_condition = []
self.default_variable_options() self.convert_variable()
self.variable_submulti()
self.convert_auto_freeze() self.convert_auto_freeze()
self.convert_groups() self.convert_groups()
self.filter_check() self.filter_check()
@ -519,34 +515,24 @@ class SpaceAnnotator(object):
varpath = self.paths.get_variable_path(family.dynamic, namespace) varpath = self.paths.get_variable_path(family.dynamic, namespace)
family.dynamic = varpath family.dynamic = varpath
def _annotate_variable(self, variable, family_mode, path, is_follower=False): def annotate_variable(self, variable, family_mode, path, is_follower=False):
if (HIGH_COMPATIBILITY and variable.type == 'choice' and variable.mode != modes_level[-1] and variable.mandatory is True and path in self.default_has_no_value):
variable.mode = modes_level[0]
if variable.type == 'choice' and is_follower and family_mode == modes_level[0] and variable.mandatory is True:
variable.mode = modes_level[0]
# if the variable is mandatory and doesn't have any value # if the variable is mandatory and doesn't have any value
# then the variable's mode is set to 'basic' # then the variable's mode is set to 'basic'
has_value = hasattr(variable, 'value') and variable.value != None has_value = hasattr(variable, 'value')
if (path not in self.has_calc and variable.mandatory is True and if variable.mandatory is True and (not has_value or is_follower):
(not has_value or is_follower) and variable.type != 'choice'):
variable.mode = modes_level[0] variable.mode = modes_level[0]
if has_value: if variable.mode != None and modes[variable.mode] < modes[family_mode] and (not is_follower or variable.mode != modes_level[0]):
if not HIGH_COMPATIBILITY or (not path.startswith(f'{VARIABLE_NAMESPACE}.services.') \ variable.mode = family_mode
and path not in self.force_no_value and path not in self.force_not_mandatory): if has_value and path not in self.force_not_mandatory:
variable.mandatory = True variable.mandatory = True
if variable.hidden is True: if variable.hidden is True:
variable.frozen = True variable.frozen = True
if not variable.auto_save is True and 'force_default_on_freeze' not in vars(variable): if not variable.auto_save is True and 'force_default_on_freeze' not in vars(variable):
variable.force_default_on_freeze = True variable.force_default_on_freeze = True
if variable.name == 'frozen' and not variable.auto_save is True:
variable.force_default_on_freeze = True
if variable.mode != None and not is_follower and modes[variable.mode] < modes[family_mode]:
variable.mode = family_mode
if variable.mode != None and variable.mode != modes_level[0] and modes[variable.mode] < modes[family_mode]:
variable.mode = family_mode
def default_variable_options(self): def convert_variable(self):
if hasattr(self.space, 'variables'): if not hasattr(self.space, 'variables'):
return
for families in self.space.variables.values(): for families in self.space.variables.values():
if hasattr(families, 'family'): if hasattr(families, 'family'):
for family in families.family.values(): for family in families.family.values():
@ -556,14 +542,6 @@ class SpaceAnnotator(object):
variable.type = 'string' variable.type = 'string'
if variable.type != 'symlink' and not hasattr(variable, 'description'): if variable.type != 'symlink' and not hasattr(variable, 'description'):
variable.description = variable.name variable.description = variable.name
def variable_submulti(self):
if hasattr(self.space, 'variables'):
for families in self.space.variables.values():
if hasattr(families, 'family'):
for family in families.family.values():
if hasattr(family, 'variable'):
for variable in family.variable.values():
if variable.submulti: if variable.submulti:
variable.multi = 'submulti' variable.multi = 'submulti'
@ -584,7 +562,6 @@ class SpaceAnnotator(object):
new_condition.param = [new_param] new_condition.param = [new_param]
new_target = self.objectspace.target() new_target = self.objectspace.target()
new_target.type = 'variable' new_target.type = 'variable'
print(variables.name, VARIABLE_NAMESPACE)
if variables.name == VARIABLE_NAMESPACE: if variables.name == VARIABLE_NAMESPACE:
path = variable.name path = variable.name
else: else:
@ -596,7 +573,6 @@ class SpaceAnnotator(object):
self.space.constraints.condition.append(new_condition) self.space.constraints.condition.append(new_condition)
def _set_valid_enum(self, variable, values, type_): def _set_valid_enum(self, variable, values, type_):
if isinstance(values, list):
variable.mandatory = True variable.mandatory = True
variable.choice = [] variable.choice = []
choices = [] choices = []
@ -628,9 +604,6 @@ class SpaceAnnotator(object):
new_value.name = values[0] new_value.name = values[0]
new_value.type = type_ new_value.type = type_
variable.value = [new_value] variable.value = [new_value]
else:
# probe choice
variable.choice = values
variable.type = 'choice' variable.type = 'choice'
def _convert_valid_enum(self, variable, path): def _convert_valid_enum(self, variable, path):
@ -694,7 +667,7 @@ class SpaceAnnotator(object):
else: else:
is_follower = False is_follower = False
path = '{}.{}.{}'.format(family.path, variable.name, follower.name) path = '{}.{}.{}'.format(family.path, variable.name, follower.name)
self._annotate_variable(follower, family_mode, path, is_follower) self.annotate_variable(follower, family_mode, path, is_follower)
# leader's mode is minimum level # leader's mode is minimum level
if modes[variable.variable[0].mode] > modes[follower.mode]: if modes[variable.variable[0].mode] > modes[follower.mode]:
follower.mode = variable.variable[0].mode follower.mode = variable.variable[0].mode
@ -707,7 +680,7 @@ class SpaceAnnotator(object):
if variable.auto_freeze is True and variable.mode != modes_level[-1]: if variable.auto_freeze is True and variable.mode != modes_level[-1]:
variable.mode = modes_level[0] variable.mode = modes_level[0]
path = '{}.{}'.format(family.path, variable.name) path = '{}.{}'.format(family.path, variable.name)
self._annotate_variable(variable, family_mode, path) self.annotate_variable(variable, family_mode, path)
def convert_fill(self): # pylint: disable=C0111,R0912 def convert_fill(self): # pylint: disable=C0111,R0912
if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'fill'): if not hasattr(self.space, 'constraints') or not hasattr(self.space.constraints, 'fill'):
@ -764,8 +737,6 @@ class SpaceAnnotator(object):
value.param = fill.param value.param = fill.param
variable = self.paths.get_variable_obj(fill.target) variable = self.paths.get_variable_obj(fill.target)
variable.value = [value] variable.value = [value]
self.force_not_mandatory.append(fill.target)
self.has_calc.append(fill.target)
del self.space.constraints.fill del self.space.constraints.fill
def filter_separators(self): # pylint: disable=C0111,R0201 def filter_separators(self): # pylint: disable=C0111,R0201

View File

@ -7,6 +7,7 @@
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="number">3</param> <param transitive="False" type="number">3</param>

View File

@ -17,6 +17,7 @@
<property>force_store_value</property> <property>force_store_value</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>basic</property> <property>basic</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="string">oui</param> <param transitive="False" type="string">oui</param>

View File

@ -15,6 +15,7 @@
</variable> </variable>
<variable doc="autosave variable" multi="False" name="autosavevar" type="string"> <variable doc="autosave variable" multi="False" name="autosavevar" type="string">
<property>force_store_value</property> <property>force_store_value</property>
<property>mandatory</property>
<property>basic</property> <property>basic</property>
<property expected="oui" inverse="False" source="rougail.general.mode_conteneur_actif" type="calculation">frozen</property> <property expected="oui" inverse="False" source="rougail.general.mode_conteneur_actif" type="calculation">frozen</property>
<property expected="oui" inverse="False" source="rougail.general.mode_conteneur_actif" type="calculation">hidden</property> <property expected="oui" inverse="False" source="rougail.general.mode_conteneur_actif" type="calculation">hidden</property>

View File

@ -17,12 +17,14 @@
<property>normal</property> <property>normal</property>
<variable doc="leader" multi="True" name="leader" type="string"/> <variable doc="leader" multi="True" name="leader" type="string"/>
<variable doc="follower1" multi="True" name="follower1" type="string"> <variable doc="follower1" multi="True" name="follower1" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
</value> </value>
</variable> </variable>
<variable doc="follower2" multi="True" name="follower2" type="string"> <variable doc="follower2" multi="True" name="follower2" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general1.leader.follower1</param> <param transitive="False" type="variable">rougail.general1.leader.follower1</param>

View File

@ -17,6 +17,7 @@
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
@ -26,6 +27,7 @@
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.leader.follower1</param> <param transitive="False" type="variable">rougail.general.leader.follower1</param>
@ -35,6 +37,7 @@
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.leader.leader</param> <param transitive="False" type="variable">rougail.general.leader.leader</param>

View File

@ -17,6 +17,7 @@
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
@ -26,6 +27,7 @@
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.leader.leader</param> <param transitive="False" type="variable">rougail.general.leader.leader</param>

View File

@ -19,6 +19,7 @@
<variable doc="leader" multi="True" name="leader" type="string"> <variable doc="leader" multi="True" name="leader" type="string">
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<property>mandatory</property>
<value name="calc_list" type="calculation"> <value name="calc_list" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
</value> </value>

View File

@ -14,12 +14,14 @@
<property>normal</property> <property>normal</property>
<variable doc="leader" multi="True" name="leader" type="string"/> <variable doc="leader" multi="True" name="leader" type="string"/>
<variable doc="follower1" multi="True" name="follower1" type="string"> <variable doc="follower1" multi="True" name="follower1" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
</value> </value>
</variable> </variable>
<variable doc="follower2" multi="True" name="follower2" type="string"> <variable doc="follower2" multi="True" name="follower2" type="string">
<property>mandatory</property>
<property>expert</property> <property>expert</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.leader.follower1</param> <param transitive="False" type="variable">rougail.general.leader.follower1</param>

View File

@ -14,12 +14,14 @@
<property>normal</property> <property>normal</property>
<variable doc="leader" multi="True" name="leader" type="string"/> <variable doc="leader" multi="True" name="leader" type="string"/>
<variable doc="follower1" multi="True" name="follower1" type="string"> <variable doc="follower1" multi="True" name="follower1" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
</value> </value>
</variable> </variable>
<variable doc="follower2" multi="True" name="follower2" type="string"> <variable doc="follower2" multi="True" name="follower2" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.leader.follower1</param> <param transitive="False" type="variable">rougail.general.leader.follower1</param>

View File

@ -16,12 +16,14 @@
<property>mandatory</property> <property>mandatory</property>
</variable> </variable>
<variable doc="follower1" multi="True" name="follower1" type="string"> <variable doc="follower1" multi="True" name="follower1" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
</value> </value>
</variable> </variable>
<variable doc="follower2" multi="True" name="follower2" type="string"> <variable doc="follower2" multi="True" name="follower2" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.leader.follower1</param> <param transitive="False" type="variable">rougail.general.leader.follower1</param>

View File

@ -21,6 +21,7 @@
</value> </value>
</variable> </variable>
<variable doc="follower2" multi="True" name="follower2" type="string"> <variable doc="follower2" multi="True" name="follower2" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general.leader.follower1</param> <param transitive="False" type="variable">rougail.general.leader.follower1</param>

View File

@ -17,12 +17,14 @@
<property>normal</property> <property>normal</property>
<variable doc="leader" multi="True" name="leader" type="string"/> <variable doc="leader" multi="True" name="leader" type="string"/>
<variable doc="follower1" multi="True" name="follower1" type="string"> <variable doc="follower1" multi="True" name="follower1" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
</value> </value>
</variable> </variable>
<variable doc="follower2" multi="True" name="follower2" type="string"> <variable doc="follower2" multi="True" name="follower2" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general1.leader.follower1</param> <param transitive="False" type="variable">rougail.general1.leader.follower1</param>

View File

@ -17,12 +17,14 @@
<property>normal</property> <property>normal</property>
<variable doc="leader" multi="True" name="leader" type="string"/> <variable doc="leader" multi="True" name="leader" type="string"/>
<variable doc="follower1" multi="True" name="follower1" type="string"> <variable doc="follower1" multi="True" name="follower1" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
</value> </value>
</variable> </variable>
<variable doc="follower2" multi="True" name="follower2" type="string"> <variable doc="follower2" multi="True" name="follower2" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general1.leader.follower1</param> <param transitive="False" type="variable">rougail.general1.leader.follower1</param>

View File

@ -17,12 +17,14 @@
<property>normal</property> <property>normal</property>
<variable doc="leader" multi="True" name="leader" type="string"/> <variable doc="leader" multi="True" name="leader" type="string"/>
<variable doc="follower1" multi="True" name="follower1" type="string"> <variable doc="follower1" multi="True" name="follower1" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
</value> </value>
</variable> </variable>
<variable doc="follower2" multi="True" name="follower2" type="string"> <variable doc="follower2" multi="True" name="follower2" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general1.leader.follower1</param> <param transitive="False" type="variable">rougail.general1.leader.follower1</param>

View File

@ -17,12 +17,14 @@
<property>normal</property> <property>normal</property>
<variable doc="leader" multi="True" name="leader" type="string"/> <variable doc="leader" multi="True" name="leader" type="string"/>
<variable doc="follower1" multi="True" name="follower1" type="string"> <variable doc="follower1" multi="True" name="follower1" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param name="valeur" transitive="False" type="string">valfill</param> <param name="valeur" transitive="False" type="string">valfill</param>
</value> </value>
</variable> </variable>
<variable doc="follower2" multi="submulti" name="follower2" type="string"> <variable doc="follower2" multi="submulti" name="follower2" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="variable">rougail.general1.leader.follower1</param> <param transitive="False" type="variable">rougail.general1.leader.follower1</param>

View File

@ -21,6 +21,7 @@
<family doc="new" name="new"> <family doc="new" name="new">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="newvar" type="string"> <variable doc="No change" multi="False" name="newvar" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param suffix="val1" transitive="False" type="variable">rougail.dyn.vardyn</param> <param suffix="val1" transitive="False" type="variable">rougail.dyn.vardyn</param>

View File

@ -7,6 +7,7 @@
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="string">value</param> <param transitive="False" type="string">value</param>

View File

@ -4,6 +4,7 @@
<family doc="general" name="general"> <family doc="general" name="general">
<property>normal</property> <property>normal</property>
<variable doc="No change" multi="False" name="mode_conteneur_actif" type="string"> <variable doc="No change" multi="False" name="mode_conteneur_actif" type="string">
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="string">value</param> <param transitive="False" type="string">value</param>

View File

@ -24,6 +24,7 @@
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<property expected="oui" inverse="False" source="rougail.general.condition" type="calculation">disabled</property> <property expected="oui" inverse="False" source="rougail.general.condition" type="calculation">disabled</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">

View File

@ -28,6 +28,7 @@
<property>force_default_on_freeze</property> <property>force_default_on_freeze</property>
<property>frozen</property> <property>frozen</property>
<property>hidden</property> <property>hidden</property>
<property>mandatory</property>
<property>normal</property> <property>normal</property>
<value name="calc_val" type="calculation"> <value name="calc_val" type="calculation">
<param transitive="False" type="string">http://localhost/</param> <param transitive="False" type="string">http://localhost/</param>