From 61cbde95d041e63409cfa7c0b5663aadd4755bf7 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Thu, 3 Nov 2022 22:16:52 +0100 Subject: [PATCH] use only boolean with yaml --- doc/check/redefine.md | 6 +- doc/condition/condition.md | 6 +- doc/condition/redefine.md | 6 +- doc/family/auto.md | 2 +- doc/family/leadership.md | 6 +- doc/family/simple.md | 2 +- doc/fill/examples.md | 8 +- doc/fill/redefine.md | 6 +- doc/fill/value.md | 4 +- doc/param/simple.md | 2 +- doc/param/variable.md | 4 +- doc/service/README.md | 10 +- doc/service/file.md | 10 +- doc/service/ip.md | 2 +- doc/target/family.md | 2 +- doc/target/list.md | 2 +- doc/target/variable.md | 2 +- doc/variable/README.md | 24 +- doc/variable/choice.md | 8 +- src/rougail/annotator/property.py | 2 +- src/rougail/annotator/variable.py | 6 +- src/rougail/data/rougail.yml | 1094 ++++------------- src/rougail/objspace.py | 19 +- src/rougail/reflector.py | 13 +- .../00load_autofreeze/yml/00-base.yml | 4 +- .../00load_autofreezeexpert/yml/00-base.yml | 4 +- .../00load_autosave/yml/00-base.yml | 2 +- .../00load_autosaveexpert/yml/00-base.yml | 2 +- .../00load_comment/yml/00-base.yml | 2 +- .../00load_notype/yml/00-base.yml | 2 +- .../dictionaries/00load_save/yml/00-base.yml | 2 +- .../00load_subfolder/yml/99-base.yml | 2 +- .../yml/subfolder/00-base.yml | 2 +- .../01auto_autofreeze/xml/00-base.xml | 2 +- .../01auto_autofreeze/yml/00-base.yml | 6 +- .../dictionaries/01auto_base/yml/00-base.yml | 2 +- .../01auto_withoutparam/yml/00-base.yml | 2 +- .../01base_file_disabled/yml/00-base.yml | 2 +- .../dictionaries/01base_float/yml/00-base.yml | 2 +- .../dictionaries/01base_multi/yml/00-base.yml | 4 +- .../01base_multi_notuniq/yml/00-base.yml | 6 +- .../01base_multi_uniq/yml/00-base.yml | 6 +- .../01base_provider/yml/00-base.yml | 2 +- .../01base_provider_hidden/yml/00-base.yml | 4 +- .../01base_value_doublequote/yml/00-base.yml | 2 +- .../01base_value_doublequote2/yml/00-base.yml | 2 +- .../01base_value_doublequote3/yml/00-base.yml | 2 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../01base_value_multi_quote/yml/00-base.yml | 4 +- .../01base_value_quote/yml/00-base.yml | 2 +- .../01boolean_no_mandatory/yml/00-base.yml | 2 +- .../01fill_autofreeze/yml/00-base.yml | 4 +- .../01fill_autosave/yml/00-base.yml | 2 +- .../01fill_mandatory/yml/00-base.yml | 2 +- .../01fill_number/yml/00-base.yml | 2 +- .../01fill_only_optional/yml/00-base.yml | 4 +- .../01fill_optional/yml/00-base.yml | 6 +- .../01fill_target_optional/yml/00-base.yml | 2 +- .../01hidden_if_in_autofreeze/yml/00-base.yml | 6 +- .../01test_redefine/yml/10-base.yml | 2 +- .../01test_redefine_base/yml/10-base.yml | 2 +- .../01test_redefine_remove/yml/10-base.yml | 2 +- .../yml/00-base.yml | 4 +- .../02fill_multi_calc_val/yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../10autosave_hidden/yml/00-base.yml | 6 +- .../yml/00-base.yml | 2 +- .../10check_optional/yml/00-base.yml | 4 +- .../10check_valid_differ_add/yml/01-base.yml | 2 +- .../yml/01-base.yml | 4 +- .../10check_valid_in_network/yml/00-base.yml | 6 +- .../yml/00-base.yml | 4 +- .../10check_valid_ipnetmask/yml/00-base.yml | 4 +- .../10fill_information_multi/yml/00-base.yml | 2 +- .../10leadership_append/yml/00-base.yml | 4 +- .../10leadership_append/yml/01-base.yml | 2 +- .../yml/00-base.yml | 6 +- .../yml/01-base.yml | 2 +- .../10leadership_append_name/yml/00-base.yml | 4 +- .../10leadership_append_name/yml/01-base.yml | 2 +- .../10leadership_auto/yml/00-base.yml | 10 +- .../10leadership_auto_index/yml/00-base.yml | 4 +- .../10leadership_autoleader/yml/00-base.yml | 8 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../10leadership_empty/yml/00_base.yml | 2 +- .../yml/00-base.yml | 6 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 6 +- .../10leadership_mandatory/yml/00-base.yml | 6 +- .../yml/00-base.yml | 8 +- .../yml/00-base.yml | 8 +- .../10leadership_multi/yml/00-base.yml | 8 +- .../10load_disabled_if_in/yml/00-base.yml | 4 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 6 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 4 +- .../10load_frozenifin_noexist/yml/00-base.yml | 4 +- .../10load_hidden_if_family/yml/00-base.yml | 2 +- .../10load_leadership/yml/00-base.yml | 4 +- .../yml/00-base.yml | 6 +- .../yml/00-base.yml | 10 +- .../yml/00-base.yml | 6 +- .../yml/00-base.yml | 4 +- .../10load_leadership_name/yml/00-base.yml | 4 +- .../yml/00-base.yml | 6 +- .../yml/00-base.yml | 4 +- .../10load_multivalue/yml/00-base.yml | 4 +- .../10valid_enum_append/yml/01-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/01-base.yml | 6 +- .../10valid_enum_leader/yml/00-base.yml | 4 +- .../10valid_enum_mandatory/yml/00-base.yml | 2 +- .../10valid_enum_multi/yml/00-base.yml | 2 +- .../10valid_enum_none/yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../11valid_enum_variable/yml/00-base.yml | 2 +- .../20family_append/yml/00-base.yml | 2 +- .../20family_append/yml/01-base.yml | 2 +- .../20family_dynamic/yml/00-base.yml | 2 +- .../20family_dynamic_calc/yml/00-base.yml | 2 +- .../20family_dynamic_calc2/yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 6 +- .../20family_dynamic_number/yml/00-base.yml | 2 +- .../20family_hidden/yml/00-base.yml | 2 +- .../20family_hidden/yml/01-base.yml | 2 +- .../20family_modeleadership/yml/00-base.yml | 4 +- .../22provider_dynamic/yml/00-base.yml | 2 +- .../22provider_dynamic_2/yml/00-base.yml | 2 +- .../30mandatory_withoutvalue/yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../40condition_base/yml/00-base.yml | 4 +- .../40condition_base_add/yml/00-base.yml | 4 +- .../40condition_base_add/yml/01-base.yml | 8 +- .../40condition_fallback/yml/00-base.yml | 4 +- .../40condition_optional/yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 6 +- .../yml/00-base.yml | 6 +- .../40ifin_leadership/yml/00-base.yml | 4 +- .../40ifin_leadershipauto/yml/00-base.yml | 6 +- .../yml/00-base.yml | 4 +- .../dictionaries/40ifin_multi/yml/00-base.yml | 6 +- .../40ifin_multi2/yml/00-base.yml | 6 +- .../40ifin_validenum/yml/00-base.yml | 2 +- .../50exists_exists/yml/00-base.yml | 2 +- .../50exists_exists/yml/01-base.yml | 2 +- .../50redefine_description/yml/00-base.yml | 2 +- .../yml/01-redefine.yml | 2 +- .../51exists_nonexists/yml/00-base.yml | 2 +- .../51exists_nonexists/yml/01-base.yml | 2 +- .../51exists_redefine/yml/00-base.yml | 2 +- .../51exists_redefine/yml/01-base.yml | 8 +- .../51redefine_auto/yml/00-base.yml | 2 +- .../51redefine_auto/yml/01-base.yml | 2 +- .../51redefine_autofill/yml/00-base.yml | 2 +- .../51redefine_autofill/yml/01-base.yml | 4 +- .../51redefine_family/yml/00-base.yml | 6 +- .../51redefine_family/yml/01-base.yml | 2 +- .../51redefine_fill/yml/00-base.yml | 2 +- .../51redefine_fill/yml/01-base.yml | 2 +- .../51redefine_fillauto/yml/01-base.yml | 4 +- .../51redefine_help/yml/00-base.yml | 2 +- .../51redefine_help/yml/01-base.yml | 4 +- .../51redefine_hidden/yml/01-redefine.yml | 4 +- .../51redefine_multi/yml/00-base.yml | 2 +- .../51redefine_multi/yml/01-redefine.yml | 4 +- .../yml/00-base.yml | 2 +- .../yml/01-base.yml | 4 +- .../yml/00-base.yml | 2 +- .../yml/01-base.yml | 4 +- .../yml/00-base.yml | 8 +- .../yml/01-base.yml | 4 +- .../51redefine_validenum/yml/00-base.yml | 2 +- .../51redefine_validenum/yml/01-redefine.yml | 6 +- .../51redefine_value/yml/00-base.yml | 2 +- .../51redefine_value/yml/01-redefine.yml | 2 +- .../51remove_fill/yml/01-base.yml | 4 +- .../52exists_redefine/yml/00-base.yml | 2 +- .../52exists_redefine/yml/01-base.yml | 4 +- .../60action_external/yml/00-base.yml | 2 +- .../yml/extra_dirs/extra/00-base.yml | 2 +- .../yml/00-base.yml | 8 +- .../yml/extra_dirs/extra/00-base.yml | 4 +- .../dictionaries/60extra_help/yml/00-base.yml | 4 +- .../yml/extra_dirs/extra/00-base.yml | 6 +- .../60extra_leadership/yml/00-base.yml | 4 +- .../yml/extra_dirs/extra/00-base.yml | 4 +- .../60extra_leadership_name/yml/00-base.yml | 4 +- .../yml/extra_dirs/extra/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../yml/extra_dirs/extra/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../yml/extra_dirs/extra/00-base.yml | 4 +- .../dictionaries/60extra_load/yml/00-base.yml | 4 +- .../yml/extra_dirs/extra/00-base.yml | 6 +- .../60extra_mandatory/yml/00-base.yml | 4 +- .../yml/extra_dirs/extra/00-base.yml | 8 +- .../60extra_name_family/yml/00-base.yml | 4 +- .../yml/extra_dirs/extra/00-base.yml | 6 +- .../60extra_no_condition/yml/00-base.yml | 4 +- .../yml/extra_dirs/extra/00-base.yml | 4 +- .../60extra_redefine/yml/00-base.yml | 4 +- .../yml/extra_dirs/extra/00-base.yml | 6 +- .../yml/extra_dirs/extra/01-redefine.yml | 4 +- .../yml/00-base.yml | 4 +- .../60familyaction/yml/00-base.yml | 2 +- .../60familyaction_mandatory/yml/00-base.yml | 2 +- .../yml/extra_dirs/extra/00-base.yml | 2 +- .../61extra_auto_freeze/yml/00-base.yml | 2 +- .../yml/extra_dirs/extra/00-base.yml | 2 +- .../dictionaries/61extra_dyn/yml/00-base.yml | 2 +- .../61extra_dyn_extra/yml/00-base.yml | 2 +- .../yml/extra_dirs/extra/00-base.yml | 2 +- .../70container_files/yml/00-base.yml | 2 +- .../yml/00-base.yml | 4 +- .../yml/00-base.yml | 6 +- .../70container_files_twice/yml/00-base.yml | 2 +- .../70container_filesmulti/yml/00-base.yml | 2 +- .../70container_filesredefine/yml/00-base.yml | 2 +- .../70container_filesredefine/yml/01-base.yml | 2 +- .../70container_new/yml/00-base.yml | 2 +- .../70container_newnocont/yml/00-base.yml | 2 +- .../70container_newwithip/yml/00-base.yml | 2 +- .../70container_save/yml/00-base.yml | 2 +- .../70service_base/yml/00-base.yml | 2 +- .../70service_disabled/yml/00-base.yml | 2 +- .../yml/00-base.yml | 4 +- .../70service_engine/yml/00-base.yml | 2 +- .../70service_engine_dash/yml/00-base.yml | 2 +- .../70service_mount/yml/00-base.yml | 2 +- .../70service_not_managed/yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../70service_servicelist_ip/yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../70service_target/yml/00-base.yml | 2 +- .../70service_target_engine/yml/00-base.yml | 2 +- .../70services_ip/yml/00-base.yml | 2 +- .../70services_ip_cidr/yml/00-base.yml | 2 +- .../70services_ip_disabled/yml/00-base.yml | 4 +- .../yml/extra_dirs/extra/00-base.yml | 2 +- .../70services_ip_iplist/yml/00-base.yml | 2 +- .../70services_ip_iplist2/yml/00-base.yml | 2 +- .../70services_ip_leadership/yml/00-base.yml | 8 +- .../70services_ip_multi/yml/00-base.yml | 4 +- .../70services_ip_network/yml/00-base.yml | 4 +- .../70services_ip_twice/yml/00-base.yml | 4 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../80empty_typeeole_eole/yml/00_base.yml | 4 +- .../80empty_typeeole_number/yml/00_base.yml | 4 +- .../80extra_externalspaceauto/yml/00-base.yml | 2 +- .../yml/extra_dirs/extra/00-base.yml | 4 +- .../yml/00-base.yml | 2 +- .../yml/extra_dirs/extra/00-base.yml | 4 +- .../yml/00-base.yml | 2 +- .../80extra_rougail/yml/00-base.yml | 4 +- .../yml/extra_dirs/rougail/00-base.yml | 6 +- .../80extra_services/yml/00-base.yml | 4 +- .../yml/extra_dirs/services/00-base.yml | 6 +- .../80family_appendaccent/yml/00-base.yml | 2 +- .../80family_appendaccent/yml/01-base.yml | 2 +- .../80family_appendaccent/yml/02-base.yml | 2 +- .../80family_change/yml/00-base.yml | 4 +- .../80family_change/yml/01-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../80family_dynamic_check/yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../80family_only_on_suffix/yml/00-base.yml | 2 +- .../80family_several/yml/00-base.yml | 8 +- .../yml/00-base.yml | 9 - .../80familyaction_accent/yml/00-base.yml | 2 +- .../80fill_baseaccent/yml/00-base.yml | 2 +- .../dictionaries/80fill_error/yml/00-base.yml | 2 +- .../dictionaries/80fill_multi/yml/00-base.yml | 2 +- .../80fill_not_exists/yml/00-base.yml | 4 +- .../80hidden_if_in_dynamic/yml/00-base.yml | 2 +- .../80hidden_if_in_filelist/yml/00-base.yml | 4 +- .../__init__.py | 0 .../no_yml => 80invalid_bool/errno_88} | 0 .../80invalid_bool/xml/00-base.xml | 8 + .../80invalid_bool/yml/00-base.yml | 7 + .../80invalid_dtd/yml/00_base.yml | 1 - .../80leadership_accent/yml/00-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../80leadership_auto_save/yml/00-base.yml | 6 +- .../80leadership_autofreeze/yml/00-base.yml | 10 +- .../80leadership_familyaccent/yml/00-base.yml | 4 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 8 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 4 +- .../yml/01-base.yml | 4 +- .../yml/00-base.yml | 4 +- .../80nil_with_value/yml/00-base.yml | 4 +- .../80override_twice/yml/00-base.yml | 17 - .../80redefine_double_error/yml/00-base.yml | 2 +- .../80redefine_double_error/yml/01-base.yml | 2 +- .../80redefine_double_error/yml/02-base.yml | 2 +- .../80redefine_error/yml/00-base.yml | 2 +- .../80redefine_error/yml/01-redefine.yml | 2 +- .../80redefine_fillerror/yml/00-base.yml | 2 +- .../80redefine_notexists/yml/00-base.yml | 2 +- .../80redefine_notexists/yml/01-redefine.yml | 2 +- .../errno_48 => 80redefine_type/__init__.py} | 0 tests/dictionaries/80redefine_type/errno_48 | 0 .../xml/00-base.xml | 0 .../xml/01-redefine.xml | 0 .../yml/00-base.yml | 2 +- .../yml/01-redefine.yml | 2 +- .../yml/00-base.yml | 2 +- .../yml/00-base.yml | 4 +- .../80services_ip_netmask/yml/00-base.yml | 4 +- .../yml/00-base.yml | 2 +- .../80services_ip_not_netmask/yml/00-base.yml | 4 +- .../80services_ip_wrong_type/yml/00-base.yml | 2 +- .../80target_list_unknown/yml/00-base.yml | 2 +- .../80valid_enum_multi_param/yml/00-base.yml | 2 +- .../yml/00-base.yml | 4 +- .../80value_not_multi/yml/00-base.yml | 2 +- .../80variable_accent/yml/00-base.yml | 2 +- .../80variable_accent/yml/01-base.yml | 2 +- .../80variable_accent/yml/02-base.yml | 2 +- .../80variable_up/yml/00-base.yml | 2 +- .../81extra_externalspace/yml/00-base.yml | 2 +- .../yml/extra_dirs/extra/00-base.yml | 4 +- .../yml/01-base.yml | 4 +- tests/test_1_flattener.py | 95 +- tests/test_others.py | 34 +- 353 files changed, 947 insertions(+), 1538 deletions(-) delete mode 100644 tests/dictionaries/80family_variable_not_same_name/yml/00-base.yml rename tests/dictionaries/{51redefine_type => 80invalid_bool}/__init__.py (100%) rename tests/dictionaries/{45multi_family_order/no_yml => 80invalid_bool/errno_88} (100%) create mode 100644 tests/dictionaries/80invalid_bool/xml/00-base.xml create mode 100644 tests/dictionaries/80invalid_bool/yml/00-base.yml delete mode 100644 tests/dictionaries/80invalid_dtd/yml/00_base.yml delete mode 100644 tests/dictionaries/80override_twice/yml/00-base.yml rename tests/dictionaries/{51redefine_type/errno_48 => 80redefine_type/__init__.py} (100%) create mode 100644 tests/dictionaries/80redefine_type/errno_48 rename tests/dictionaries/{51redefine_type => 80redefine_type}/xml/00-base.xml (100%) rename tests/dictionaries/{51redefine_type => 80redefine_type}/xml/01-redefine.xml (100%) rename tests/dictionaries/{51redefine_type => 80redefine_type}/yml/00-base.yml (90%) rename tests/dictionaries/{51redefine_type => 80redefine_type}/yml/01-redefine.yml (85%) diff --git a/doc/check/redefine.md b/doc/check/redefine.md index 8b1fbde76..fedf67dfd 100644 --- a/doc/check/redefine.md +++ b/doc/check/redefine.md @@ -47,7 +47,7 @@ En YAML : variables: - variable: name: my_variable - redefine: 'True' + redefine: true constraints: - check: - name: isspace @@ -103,6 +103,6 @@ En YAML : variables: - variable: name: my_variable - redefine: 'True' - remove_check: 'True' + redefine: true + remove_check: true ``` diff --git a/doc/condition/condition.md b/doc/condition/condition.md index 890d4a901..9821885a4 100644 --- a/doc/condition/condition.md +++ b/doc/condition/condition.md @@ -36,7 +36,7 @@ constraints: - name: hidden_if_in source: condition param: - - text: 'True' + - text: true target: - text: my_variable ``` @@ -119,8 +119,8 @@ En YAML : - condition: - name: hidden_if_in source: condition - optional: 'True' - apply_on_fallback: 'False' + optional: true + apply_on_fallback: false param: - text: 'yes' - text: 'maybe' diff --git a/doc/condition/redefine.md b/doc/condition/redefine.md index bcaa5443c..664f8c90c 100644 --- a/doc/condition/redefine.md +++ b/doc/condition/redefine.md @@ -34,7 +34,7 @@ constraints: - name: hidden_if_in source: condition param: - - text: 'True' + - text: true target: - text: my_variable ``` @@ -53,6 +53,6 @@ En YAML : variables: - variable: name: condition - redefine: 'True' - remove_condition: 'True' + redefine: true + remove_condition: true ``` diff --git a/doc/family/auto.md b/doc/family/auto.md index fdd31de70..55f516bc0 100644 --- a/doc/family/auto.md +++ b/doc/family/auto.md @@ -21,7 +21,7 @@ En YAML : variables: - variable: name: variable - multi: 'True' + multi: true value: - text: 'val1' - text: 'val2' diff --git a/doc/family/leadership.md b/doc/family/leadership.md index 7fa395276..838267c12 100644 --- a/doc/family/leadership.md +++ b/doc/family/leadership.md @@ -49,16 +49,16 @@ En YAML : variables: - family: name: family - leadership: 'True' + leadership: true variables: - variable: name: leader - multi: 'True' + multi: true - variable: name: follower1 - variable: name: follower2 - multi: 'True' + multi: true ``` ## Ajout d'une nouvelle variable suiveuse diff --git a/doc/family/simple.md b/doc/family/simple.md index 2705218e8..c3f545c14 100644 --- a/doc/family/simple.md +++ b/doc/family/simple.md @@ -124,5 +124,5 @@ En YAML : ``` - family: name: my_family - hidden: 'True' + hidden: true ``` diff --git a/doc/fill/examples.md b/doc/fill/examples.md index f8c8954e3..64808705b 100644 --- a/doc/fill/examples.md +++ b/doc/fill/examples.md @@ -22,7 +22,7 @@ variables: - variable: name: zones_list type: string - multi: 'True' + multi: true value: - text: 'zone1' - text: 'zone2' @@ -30,8 +30,8 @@ variables: - variable: name: netwokd_configurations type: filename - multi: 'True' - hidden: 'True' + multi: true + hidden: true ``` Calculons la valeur de la seconde variable à partir de la première : @@ -63,7 +63,7 @@ constraints: - name: join - name: multi type: boolean - text: 'True' + text: true target: - text: netwokd_configurations ``` diff --git a/doc/fill/redefine.md b/doc/fill/redefine.md index a701f52e1..42fd5a49e 100644 --- a/doc/fill/redefine.md +++ b/doc/fill/redefine.md @@ -47,7 +47,7 @@ En YAML : variables: - variable: name: my_calculated_variable - redefine: 'True' + redefine: true constraints: - fill: - name: return_yes @@ -103,6 +103,6 @@ En YAML : variables: - variable: name: my_calculated_variable - redefine: 'True' - remove_fill: 'True' + redefine: true + remove_fill: true ``` diff --git a/doc/fill/value.md b/doc/fill/value.md index 03fd61dd6..effe360c1 100644 --- a/doc/fill/value.md +++ b/doc/fill/value.md @@ -75,7 +75,7 @@ En YAML : variables: - variable: name: my_calculated_variable - hidden: 'True' + hidden: true ``` Si une condition "hidden_if_in" est spécifié à la variable, la valeur sera modifiable par l'utilisateur si elle n'est pas cachée mais elle sera systèmatiquement calculée (même si elle a déjà était modifiée) si la variable est cachée. @@ -121,7 +121,7 @@ variables: name: suffixes type: string description: Suffixes of dynamic family - multi: 'True' + multi: true value: - text: val1 - text: val2 diff --git a/doc/param/simple.md b/doc/param/simple.md index 80ac70e88..9890d5204 100644 --- a/doc/param/simple.md +++ b/doc/param/simple.md @@ -56,7 +56,7 @@ En YAML : ``` param: - type: boolean - text: 'True' + text: true ``` # Paramètre de type "nil" diff --git a/doc/param/variable.md b/doc/param/variable.md index 0d8854a11..5e6e1ac64 100644 --- a/doc/param/variable.md +++ b/doc/param/variable.md @@ -31,7 +31,7 @@ En YAML : ``` param: - type: variable - optional: 'True' + optional: true text: unknow_variable ``` @@ -54,7 +54,7 @@ En YAML : ``` param: - type: variable - propertyerror: 'False' + propertyerror: false text: variable1 ``` diff --git a/doc/service/README.md b/doc/service/README.md index c2247b9bc..c5f07d7b7 100644 --- a/doc/service/README.md +++ b/doc/service/README.md @@ -101,7 +101,7 @@ En YAML : ``` - service: - name: ldap_client - manage: 'False' + manage: false ``` Un service factice est généralement une service qui n'existe pas réellement (par exemple si on configure un client). Il n'est là que pour contenir des fichiers. @@ -119,7 +119,7 @@ En YAML : ``` - service: - name: test - disabled: 'True' + disabled: true ``` Dans ce cas, le service et les éléments qu'il compose ([fichier](file.md), [IP](ip.md) et [réécriture](override.md) seront désactivés. @@ -158,7 +158,7 @@ constraints: name: disabled_if_in source: condition param: - - text: 'False' + - text: false target: - type: servicelist text: test @@ -181,6 +181,6 @@ En YAML : ``` - service: - name: test - disabled: 'True' - undisable: 'True' + disabled: true + undisable: true ``` diff --git a/doc/service/file.md b/doc/service/file.md index b80b99a7c..168061b4e 100644 --- a/doc/service/file.md +++ b/doc/service/file.md @@ -109,7 +109,7 @@ services: variables: - variable: name: my_variable - multi: 'True' + multi: true value: - text: /etc/squid1/squid.conf - text: /etc/squid2/squid.conf @@ -157,13 +157,13 @@ services: variables: - variable: name: my_variable1 - multi: 'True' + multi: true value: - text: /etc/squid1/squid.conf - text: /etc/squid2/squid.conf - variable: name: my_variable2 - multi: 'True' + multi: true value: - text: squid1 - text: squid2 @@ -207,7 +207,7 @@ En YAML : ``` file: -- disabled: 'True' +- disabled: true text: /etc/squid/squid.conf ``` @@ -248,7 +248,7 @@ constraints: - name: disabled_if_in source: condition param: - - text: 'False' + - text: false target: - type: filelist text: squid diff --git a/doc/service/ip.md b/doc/service/ip.md index 0dc67e070..b1f2d98e5 100644 --- a/doc/service/ip.md +++ b/doc/service/ip.md @@ -81,7 +81,7 @@ constraints: - name: disabled_if_in source: condition param: - - text: 'False' + - text: false target: - type: iplist text: test_ip diff --git a/doc/target/family.md b/doc/target/family.md index e75de3070..a324ccae7 100644 --- a/doc/target/family.md +++ b/doc/target/family.md @@ -25,6 +25,6 @@ En YAML : ``` target: - type: family - optional: 'True' + optional: true text: my_family ``` diff --git a/doc/target/list.md b/doc/target/list.md index 8a0e6e198..b1625ebe7 100644 --- a/doc/target/list.md +++ b/doc/target/list.md @@ -63,6 +63,6 @@ En YAML : ``` target: - type: filelist - optional: 'True' + optional: true text: unknown ``` diff --git a/doc/target/variable.md b/doc/target/variable.md index 8b443a1ec..c40ce188c 100644 --- a/doc/target/variable.md +++ b/doc/target/variable.md @@ -23,6 +23,6 @@ En YAML : ``` target: -- optional: 'True' +- optional: true text: my_variable ``` diff --git a/doc/variable/README.md b/doc/variable/README.md index ea32dccc4..765b1d39f 100644 --- a/doc/variable/README.md +++ b/doc/variable/README.md @@ -120,7 +120,7 @@ En YAML : ``` - variable: name: my_variable - multi: 'True' + multi: true ``` ## Variable invisible @@ -141,7 +141,7 @@ En YAML : ``` - variable: name: my_variable - hidden: 'True' + hidden: true ``` ## Variable désactive @@ -161,7 +161,7 @@ En YAML : ``` - variable: name: my_variable - disabled: 'True' + disabled: true ``` ## Variable obligatoire @@ -177,7 +177,7 @@ En YAML : ``` - variable: name: my_variable - mandatory: 'True' + mandatory: true ``` Les variables booléans sont par défaut obligatoire. Pour qu'une variable booléan ne soit pas obligatoire il faut le préciser explicitement : @@ -192,7 +192,7 @@ En YAML : - variable: name: my_variable type: boolean - mandatory: 'False' + mandatory: false ``` Les variables avec une valeur par défaut (non calculée) sont également automatiquement obligatoire. @@ -230,7 +230,7 @@ En YAML : ``` - variable: name: my_variable - multi: 'True' + multi: true value: - text: value 1 - text: value 2 @@ -274,7 +274,7 @@ En YAML : ``` - variable: name: my_variable - redefine: 'True' + redefine: true description: New description ``` @@ -291,7 +291,7 @@ En YAML : ``` - variable: name: my_variable - exists: 'False' + exists: false ``` Si cette variable existe dans un autre dictionnaire, elle ne sera pas modifié ni recréé @@ -309,8 +309,8 @@ En YAML : ``` - variable: name: my_variable - exists: 'True' - hidden: 'True' + exists: true + hidden: true ``` ## Variable à valeur automatiquement modifiée @@ -330,7 +330,7 @@ En YAML : ``` - variable: name: my_variable - auto_save: 'True' + auto_save: true value: - text: my_value ``` @@ -365,7 +365,7 @@ En YAML : - text: 'False - variable: name: my_variable - auto_freeze: 'True' + auto_freeze: true ``` Dans ce cas la valeur est fixée à la valeur actuelle et elle ne sera plus modifiable par l'utilisateur. diff --git a/doc/variable/choice.md b/doc/variable/choice.md index 26bffb674..c47d04110 100644 --- a/doc/variable/choice.md +++ b/doc/variable/choice.md @@ -79,7 +79,7 @@ En YAML : - type: number text: '3' - type: boolean - text: 'True' + text: true - type: 'nil' ``` @@ -100,7 +100,7 @@ En YAML : ``` - variable: name: my_variable - redefine: 'True' + redefine: true choice: - text: val4 ``` @@ -121,8 +121,8 @@ En YAML : ``` - variable: name: my_variable - redefine: 'True' - remove_choice: 'True' + redefine: true + remove_choice: true choice: - text: val1 - text: val2 diff --git a/src/rougail/annotator/property.py b/src/rougail/annotator/property.py index f90168852..0ce81be70 100644 --- a/src/rougail/annotator/property.py +++ b/src/rougail/annotator/property.py @@ -84,7 +84,7 @@ class Annotator(Walk): variable.properties.append(prop) setattr(variable, prop, None) if hasattr(variable, 'unique') and variable.unique != 'nil': - if variable.unique == 'False': + if variable.unique == 'False' or variable.unique is False: variable.properties.append('notunique') else: variable.properties.append('unique') diff --git a/src/rougail/annotator/variable.py b/src/rougail/annotator/variable.py index a45702904..de629b13d 100644 --- a/src/rougail/annotator/variable.py +++ b/src/rougail/annotator/variable.py @@ -168,7 +168,11 @@ class Annotator(Walk): # pylint: disable=R0903 else: if not hasattr(value, 'type'): value.type = variable.type - value.name = CONVERT_OPTION.get(value.type, {}).get('func', str)(value.name) + try: + value.name = CONVERT_OPTION.get(value.type, {}).get('func', str)(value.name) + except Exception as err: + msg = _(f'the variable "{variable.name}" has an incorrect value "{value.name}" with "{variable.type}" type') + raise DictConsistencyError(msg, 88, variable.xmlfiles) value_to_del.sort(reverse=True) for idx in value_to_del: del variable.value[idx] diff --git a/src/rougail/data/rougail.yml b/src/rougail/data/rougail.yml index 3011525dc..e97c1ed91 100644 --- a/src/rougail/data/rougail.yml +++ b/src/rougail/data/rougail.yml @@ -20,6 +20,7 @@ mapping: mapping: text: required: false + type: str iplist: type: str netmask: @@ -40,16 +41,14 @@ mapping: mapping: text: required: false + type: str file_type: type: str enum: - "filename" - "variable" disabled: - type: str - enum: - - "True" - - "False" + type: bool included: type: str enum: @@ -64,10 +63,7 @@ mapping: - "jinja2" - "creole_legacy" redefine: - type: str - enum: - - "True" - - "False" + type: bool filelist: type: str group_type: @@ -111,10 +107,7 @@ mapping: name: type: str undisable: - type: str - enum: - - "True" - - "False" + type: bool type: type: str enum: @@ -132,17 +125,11 @@ mapping: - "creole" - "jinja2" disabled: - type: str - enum: - - "True" - - "False" + type: bool servicelist: type: str manage: - type: str - enum: - - "True" - - "False" + type: bool variables: required: false type: seq @@ -168,6 +155,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -183,15 +171,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -214,6 +196,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -231,73 +214,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -352,6 +295,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -367,15 +311,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -398,6 +336,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -415,73 +354,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -537,6 +436,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -552,15 +452,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -583,6 +477,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -600,73 +495,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -722,6 +577,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -737,15 +593,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -768,6 +618,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -785,73 +636,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -907,6 +718,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -922,15 +734,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -953,6 +759,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -970,73 +777,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -1073,17 +840,11 @@ mapping: name: type: str leadership: - type: str - enum: - - "True" - - "False" + type: bool dynamic: type: str hidden: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str help: @@ -1093,17 +854,11 @@ mapping: name: type: str leadership: - type: str - enum: - - "True" - - "False" + type: bool dynamic: type: str hidden: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str help: @@ -1113,17 +868,11 @@ mapping: name: type: str leadership: - type: str - enum: - - "True" - - "False" + type: bool dynamic: type: str hidden: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str help: @@ -1133,17 +882,11 @@ mapping: name: type: str leadership: - type: str - enum: - - "True" - - "False" + type: bool dynamic: type: str hidden: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str help: @@ -1174,6 +917,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -1189,15 +933,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -1220,6 +958,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -1237,73 +976,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -1358,6 +1057,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -1373,15 +1073,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -1404,6 +1098,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -1421,73 +1116,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -1524,17 +1179,11 @@ mapping: name: type: str leadership: - type: str - enum: - - "True" - - "False" + type: bool dynamic: type: str hidden: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str help: @@ -1565,6 +1214,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -1580,15 +1230,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -1611,6 +1255,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -1628,73 +1273,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -1749,6 +1354,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -1764,15 +1370,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -1795,6 +1395,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -1812,73 +1413,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -1915,17 +1476,11 @@ mapping: name: type: str leadership: - type: str - enum: - - "True" - - "False" + type: bool dynamic: type: str hidden: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str help: @@ -1956,6 +1511,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -1971,15 +1527,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -2002,6 +1552,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -2019,73 +1570,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -2140,6 +1651,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -2155,15 +1667,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -2186,6 +1692,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -2203,73 +1710,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -2306,17 +1773,11 @@ mapping: name: type: str leadership: - type: str - enum: - - "True" - - "False" + type: bool dynamic: type: str hidden: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str help: @@ -2347,6 +1808,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -2362,15 +1824,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str type: @@ -2393,6 +1849,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -2410,73 +1867,33 @@ mapping: provider: type: str remove_fill: - type: str - enum: - - "True" - - "False" + type: bool remove_condition: - type: str - enum: - - "True" - - "False" + type: bool remove_check: - type: str - enum: - - "True" - - "False" + type: bool remove_choice: - type: str - enum: - - "True" - - "False" + type: bool mode: type: str auto_save: - type: str - enum: - - "True" - - "False" + type: bool auto_freeze: - type: str - enum: - - "True" - - "False" + type: bool mandatory: - type: str - enum: - - "True" - - "False" + type: bool exists: - type: str - enum: - - "True" - - "False" + type: bool redefine: - type: str - enum: - - "True" - - "False" + type: bool unique: - type: str - enum: - - "nil" - - "True" - - "False" + type: bool multi: - type: str - enum: - - "True" - - "False" + type: bool disabled: - type: str - enum: - - "True" - - "False" + type: bool hidden: - type: str - enum: - - "True" - - "False" + type: bool help: type: str description: @@ -2528,6 +1945,7 @@ mapping: mapping: text: required: false + type: str type: type: str enum: @@ -2537,10 +1955,7 @@ mapping: - "filelist" - "iplist" optional: - type: str - enum: - - "True" - - "False" + type: bool param: required: false type: seq @@ -2549,6 +1964,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -2564,15 +1980,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str name: @@ -2591,6 +2001,7 @@ mapping: mapping: text: required: false + type: str type: type: str enum: @@ -2600,10 +2011,7 @@ mapping: - "filelist" - "iplist" optional: - type: str - enum: - - "True" - - "False" + type: bool param: required: false type: seq @@ -2612,6 +2020,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -2627,15 +2036,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str name: @@ -2659,6 +2062,7 @@ mapping: mapping: text: required: false + type: str type: type: str enum: @@ -2668,10 +2072,7 @@ mapping: - "filelist" - "iplist" optional: - type: str - enum: - - "True" - - "False" + type: bool param: required: false type: seq @@ -2680,6 +2081,7 @@ mapping: mapping: text: required: false + type: any type: type: str enum: @@ -2695,15 +2097,9 @@ mapping: - "suffix" - "index" optional: - type: str - enum: - - "True" - - "False" + type: bool propertyerror: - type: str - enum: - - "True" - - "False" + type: bool name: type: str name: @@ -2716,15 +2112,9 @@ mapping: - "mandatory_if_in" - "mandatory_if_not_in" apply_on_fallback: - type: str - enum: - - "True" - - "False" + type: bool optional: - type: str - enum: - - "True" - - "False" + type: bool source: type: str version: diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py index c21d74c00..0e857f9a8 100644 --- a/src/rougail/objspace.py +++ b/src/rougail/objspace.py @@ -62,7 +62,7 @@ class RootRougailObject: # pylint: disable=R0903 if not isinstance(xmlfiles, list): xmlfiles = [xmlfiles] self.xmlfiles = xmlfiles - if name: + if name is not None: self.name = name @@ -94,7 +94,9 @@ def convert_boolean(value: str) -> bool: return value if value == 'True': return True - return False + elif value == 'False': + return False + raise Exception(f'unknown boolean value {value}') class RougailObjSpace: @@ -319,8 +321,11 @@ class RougailObjSpace: return child.attrib['name'] + '.' + child.attrib.get('type', 'service') if 'name' in child.attrib: return child.attrib['name'] - if child.text and child.tag in self.forced_text_elts_as_name: - return child.text.strip() + if child.text is not None and child.tag in self.forced_text_elts_as_name: + text = child.text + if isinstance(text, str): + text = text.strip() + return text return None def create_or_update_redefinable_object(self, @@ -411,8 +416,10 @@ class RougailObjSpace: """ if child.text is None or child.tag in self.forced_text_elts_as_name: return - text = child.text.strip() - if text: + text = child.text + if isinstance(text, str): + text = text.strip() + if text != '': variableobj.text = text def set_attributes(self, diff --git a/src/rougail/reflector.py b/src/rougail/reflector.py index 97d1af0aa..7b85358a2 100644 --- a/src/rougail/reflector.py +++ b/src/rougail/reflector.py @@ -1,4 +1,4 @@ -"""load XML file from directory +"""load XML and YAML file from directory Created by: EOLE (http://eole.orion.education.fr) @@ -32,6 +32,7 @@ from os.path import join, isfile from os import listdir from lxml.etree import DTD, parse, XMLSyntaxError # pylint: disable=E0611 +from pykwalify.compat import yml from pykwalify.core import Core from pykwalify.errors import SchemaError @@ -41,6 +42,7 @@ from .error import DictConsistencyError FORCE_SUBYAML = ['override'] +SCHEMA_DATA = {} class Reflector: @@ -65,6 +67,7 @@ class Reflector: if not isfile(yamlschema_filename): raise IOError(_(f"no such YAML Schema file: {yamlschema_filename}")) self.yamlschema_filename = yamlschema_filename + self.schema_data = None def load_dictionaries_from_folders(self, folders: List[str], @@ -114,8 +117,14 @@ class Reflector: def load_yml_file(self, filename: str, ): + global SCHEMA_DATA + if self.yamlschema_filename not in SCHEMA_DATA: + with open(self.yamlschema_filename, 'r') as fh: + SCHEMA_DATA[self.yamlschema_filename] = yml.load(fh) try: - document = Core(source_file=filename, schema_files=[self.yamlschema_filename]) + document = Core(source_file=filename, + schema_data=SCHEMA_DATA[self.yamlschema_filename], + ) except XMLSyntaxError as err: raise DictConsistencyError(_(f'not a XML file: {err}'), 52, [filename]) from err try: diff --git a/tests/dictionaries/00load_autofreeze/yml/00-base.yml b/tests/dictionaries/00load_autofreeze/yml/00-base.yml index 7fe5ac004..46e2f524c 100644 --- a/tests/dictionaries/00load_autofreeze/yml/00-base.yml +++ b/tests/dictionaries/00load_autofreeze/yml/00-base.yml @@ -2,11 +2,11 @@ version: '0.10' variables: - variable: name: myvar - auto_freeze: 'True' + auto_freeze: true value: - text: 'no' - variable: name: server_deployed type: boolean value: - - text: 'False' + - text: false diff --git a/tests/dictionaries/00load_autofreezeexpert/yml/00-base.yml b/tests/dictionaries/00load_autofreezeexpert/yml/00-base.yml index 71e503b69..1e1a4b0db 100644 --- a/tests/dictionaries/00load_autofreezeexpert/yml/00-base.yml +++ b/tests/dictionaries/00load_autofreezeexpert/yml/00-base.yml @@ -2,7 +2,7 @@ version: '0.10' variables: - variable: name: my_var - auto_freeze: 'True' + auto_freeze: true mode: expert value: - text: 'no' @@ -10,4 +10,4 @@ variables: name: server_deployed type: boolean value: - - text: 'False' + - text: false diff --git a/tests/dictionaries/00load_autosave/yml/00-base.yml b/tests/dictionaries/00load_autosave/yml/00-base.yml index 6f1b7e59c..6f0501647 100644 --- a/tests/dictionaries/00load_autosave/yml/00-base.yml +++ b/tests/dictionaries/00load_autosave/yml/00-base.yml @@ -11,6 +11,6 @@ variables: name: mode_conteneur_actif type: string description: No change - auto_save: 'True' + auto_save: true value: - text: non diff --git a/tests/dictionaries/00load_autosaveexpert/yml/00-base.yml b/tests/dictionaries/00load_autosaveexpert/yml/00-base.yml index e0f1dfb9a..b6ee766ad 100644 --- a/tests/dictionaries/00load_autosaveexpert/yml/00-base.yml +++ b/tests/dictionaries/00load_autosaveexpert/yml/00-base.yml @@ -11,7 +11,7 @@ variables: name: mode_conteneur_actif type: string description: No change - auto_save: 'True' + auto_save: true mode: expert value: - text: non diff --git a/tests/dictionaries/00load_comment/yml/00-base.yml b/tests/dictionaries/00load_comment/yml/00-base.yml index b0ee492a2..9b4819ab1 100644 --- a/tests/dictionaries/00load_comment/yml/00-base.yml +++ b/tests/dictionaries/00load_comment/yml/00-base.yml @@ -8,6 +8,6 @@ variables: name: mode_conteneur_actif type: string description: No change - hidden: 'True' + hidden: true value: - text: non diff --git a/tests/dictionaries/00load_notype/yml/00-base.yml b/tests/dictionaries/00load_notype/yml/00-base.yml index cc328a176..5b826e614 100644 --- a/tests/dictionaries/00load_notype/yml/00-base.yml +++ b/tests/dictionaries/00load_notype/yml/00-base.yml @@ -8,7 +8,7 @@ variables: name: mode_conteneur_actif type: string description: No change - hidden: 'True' + hidden: true value: - text: non - variable: diff --git a/tests/dictionaries/00load_save/yml/00-base.yml b/tests/dictionaries/00load_save/yml/00-base.yml index b0ee492a2..9b4819ab1 100644 --- a/tests/dictionaries/00load_save/yml/00-base.yml +++ b/tests/dictionaries/00load_save/yml/00-base.yml @@ -8,6 +8,6 @@ variables: name: mode_conteneur_actif type: string description: No change - hidden: 'True' + hidden: true value: - text: non diff --git a/tests/dictionaries/00load_subfolder/yml/99-base.yml b/tests/dictionaries/00load_subfolder/yml/99-base.yml index b0ee492a2..9b4819ab1 100644 --- a/tests/dictionaries/00load_subfolder/yml/99-base.yml +++ b/tests/dictionaries/00load_subfolder/yml/99-base.yml @@ -8,6 +8,6 @@ variables: name: mode_conteneur_actif type: string description: No change - hidden: 'True' + hidden: true value: - text: non diff --git a/tests/dictionaries/00load_subfolder/yml/subfolder/00-base.yml b/tests/dictionaries/00load_subfolder/yml/subfolder/00-base.yml index 75c3d0581..fe8199b1f 100644 --- a/tests/dictionaries/00load_subfolder/yml/subfolder/00-base.yml +++ b/tests/dictionaries/00load_subfolder/yml/subfolder/00-base.yml @@ -8,6 +8,6 @@ variables: name: mode_conteneur_actif1 type: string description: No change - hidden: 'True' + hidden: true value: - text: non diff --git a/tests/dictionaries/01auto_autofreeze/xml/00-base.xml b/tests/dictionaries/01auto_autofreeze/xml/00-base.xml index fcfc4feb4..64580adeb 100644 --- a/tests/dictionaries/01auto_autofreeze/xml/00-base.xml +++ b/tests/dictionaries/01auto_autofreeze/xml/00-base.xml @@ -2,7 +2,7 @@ - no + False