feat(#21): add examples attributes
This commit is contained in:
parent
a827ca2225
commit
b21c13fea7
1 changed files with 18 additions and 2 deletions
|
@ -77,6 +77,7 @@ class Annotator(Walk): # pylint: disable=R0903
|
||||||
self.basic_types = {str: "string", int: "number", bool: "boolean", float: "float"}
|
self.basic_types = {str: "string", int: "number", bool: "boolean", float: "float"}
|
||||||
self.convert_variable()
|
self.convert_variable()
|
||||||
self.convert_test()
|
self.convert_test()
|
||||||
|
self.convert_examples()
|
||||||
self.convert_help()
|
self.convert_help()
|
||||||
self.verify_choices()
|
self.verify_choices()
|
||||||
|
|
||||||
|
@ -105,6 +106,8 @@ class Annotator(Walk): # pylint: disable=R0903
|
||||||
# choice type inference from the `choices` attribute
|
# choice type inference from the `choices` attribute
|
||||||
if variable.choices is not None:
|
if variable.choices is not None:
|
||||||
variable.type = "choice"
|
variable.type = "choice"
|
||||||
|
elif variable.regexp is not None:
|
||||||
|
variable.type = "regexp"
|
||||||
elif variable.default not in [None, []]:
|
elif variable.default not in [None, []]:
|
||||||
if isinstance(variable.default, list):
|
if isinstance(variable.default, list):
|
||||||
tested_value = variable.default[0]
|
tested_value = variable.default[0]
|
||||||
|
@ -143,8 +146,11 @@ class Annotator(Walk): # pylint: disable=R0903
|
||||||
variable.hidden = family.hidden
|
variable.hidden = family.hidden
|
||||||
variable.hidden = None
|
variable.hidden = None
|
||||||
if variable.choices is not None and variable.type != 'choice':
|
if variable.choices is not None and variable.type != 'choice':
|
||||||
msg = _(f'the variable "{variable.path}" has choice attribut but has not the "choice" type')
|
msg = _(f'the variable "{variable.path}" has choices attribut but has not the "choice" type')
|
||||||
raise DictConsistencyError(msg, 11, variable.xmlfiles)
|
raise DictConsistencyError(msg, 11, variable.xmlfiles)
|
||||||
|
if variable.regexp is not None and variable.type != 'regexp':
|
||||||
|
msg = _(f'the variable "{variable.path}" has regexp attribut but has not the "regexp" type')
|
||||||
|
raise DictConsistencyError(msg, 37, variable.xmlfiles)
|
||||||
|
|
||||||
def convert_test(self):
|
def convert_test(self):
|
||||||
"""Convert variable tests value"""
|
"""Convert variable tests value"""
|
||||||
|
@ -152,12 +158,22 @@ class Annotator(Walk): # pylint: disable=R0903
|
||||||
if variable.type == "symlink":
|
if variable.type == "symlink":
|
||||||
continue
|
continue
|
||||||
if variable.test is None:
|
if variable.test is None:
|
||||||
# with we want remove test, we set "" has test value
|
|
||||||
continue
|
continue
|
||||||
self.objectspace.informations.add(
|
self.objectspace.informations.add(
|
||||||
variable.path, "test", tuple(variable.test)
|
variable.path, "test", tuple(variable.test)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def convert_examples(self):
|
||||||
|
"""Convert variable tests value"""
|
||||||
|
for variable in self.get_variables():
|
||||||
|
if variable.type == "symlink":
|
||||||
|
continue
|
||||||
|
if variable.examples is None:
|
||||||
|
continue
|
||||||
|
self.objectspace.informations.add(
|
||||||
|
variable.path, "examples", tuple(variable.examples)
|
||||||
|
)
|
||||||
|
|
||||||
def convert_help(self):
|
def convert_help(self):
|
||||||
"""Convert variable help"""
|
"""Convert variable help"""
|
||||||
for variable in self.get_variables():
|
for variable in self.get_variables():
|
||||||
|
|
Loading…
Reference in a new issue