feat: in structural commandline very is there is conflict alternative name

This commit is contained in:
egarette@silique.fr 2024-09-01 12:15:19 +02:00 committed by gwen
parent b21c13fea7
commit 1389929371

View file

@ -30,6 +30,7 @@ class Annotator(Walk):
def __init__(self, objectspace, *args) -> None:
if not objectspace.paths:
return
self.alternative_names = {}
self.objectspace = objectspace
not_for_commandlines = []
for family in self.get_families():
@ -59,6 +60,17 @@ class Annotator(Walk):
return
alternative_name = variable.alternative_name
variable_path = variable.path
all_letters = ''
for letter in alternative_name:
all_letters += letter
if all_letters == 'h':
msg = _(f'alternative_name "{alternative_name}" conflict with "--help"')
raise DictConsistencyError(msg, 202, variable.xmlfiles)
if all_letters in self.alternative_names:
msg = _(f'conflict alternative_name "{alternative_name}": "{variable_path}" and "{self.alternative_names[all_letters]}"')
raise DictConsistencyError(msg, 202, variable.xmlfiles)
self.alternative_names[alternative_name] = variable_path
if '.' not in variable_path:
path = alternative_name
else:
@ -71,7 +83,7 @@ class Annotator(Walk):
raise DictConsistencyError(_(f'negative_description is mandatory for boolean variable, but "{variable.path}" hasn\'t'), 200, variable.xmlfiles)
return
if variable.type != 'boolean':
raise DictConsistencyError(_(f'negative_description is only available for boolean variable, but "{variable.path}" is "{variable.type}"'), 200, variable.xmlfiles)
raise DictConsistencyError(_(f'negative_description is only available for boolean variable, but "{variable.path}" is "{variable.type}"'), 201, variable.xmlfiles)
self.objectspace.informations.add(
variable.path, "negative_description", variable.negative_description
)