From a058d4a20d3cf6e3609066f857e90310817d0e21 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 11 Jun 2022 08:47:57 +0200 Subject: [PATCH] test if auto_freeze variable exists --- src/rougail/annotator/condition.py | 6 +++++- .../80load_autofreeze_no_variable/00-base.xml | 8 ++++++++ .../80load_autofreeze_no_variable/__init__.py | 0 tests/dictionaries/80load_autofreeze_no_variable/errno_81 | 0 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/dictionaries/80load_autofreeze_no_variable/00-base.xml create mode 100644 tests/dictionaries/80load_autofreeze_no_variable/__init__.py create mode 100644 tests/dictionaries/80load_autofreeze_no_variable/errno_81 diff --git a/src/rougail/annotator/condition.py b/src/rougail/annotator/condition.py index 790771a42..3286bf0a1 100644 --- a/src/rougail/annotator/condition.py +++ b/src/rougail/annotator/condition.py @@ -83,10 +83,14 @@ class Annotator(TargetAnnotator, ParamAnnotator, Walk): variable.force_store_value = True if variable.auto_save: continue + auto_freeze_variable = self.objectspace.rougailconfig['auto_freeze_variable'] + if not self.objectspace.paths.path_is_defined(auto_freeze_variable): + msg = _(f'the variable "{variable.name}" is auto_freeze but there is no variable "{auto_freeze_variable}"') + raise DictConsistencyError(msg, 81, variable.xmlfiles) new_condition = self.objectspace.condition(variable.xmlfiles) new_condition.name = 'auto_frozen_if_in' new_condition.namespace = variable.namespace - new_condition.source = self.objectspace.rougailconfig['auto_freeze_variable'] + new_condition.source = auto_freeze_variable new_param = self.objectspace.param(variable.xmlfiles) new_param.text = True new_condition.param = [new_param] diff --git a/tests/dictionaries/80load_autofreeze_no_variable/00-base.xml b/tests/dictionaries/80load_autofreeze_no_variable/00-base.xml new file mode 100644 index 000000000..97339cfa5 --- /dev/null +++ b/tests/dictionaries/80load_autofreeze_no_variable/00-base.xml @@ -0,0 +1,8 @@ + + + + + no + + + diff --git a/tests/dictionaries/80load_autofreeze_no_variable/__init__.py b/tests/dictionaries/80load_autofreeze_no_variable/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dictionaries/80load_autofreeze_no_variable/errno_81 b/tests/dictionaries/80load_autofreeze_no_variable/errno_81 new file mode 100644 index 000000000..e69de29bb