From 9c2fd7e064647346fe1ffde0f7f73c314c2c33cd Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 24 Jan 2023 15:06:33 -0500 Subject: [PATCH] [22] update conditions --- VERSION | 2 +- docs/conf.py | 6 ++++-- modules/meta.py | 50 +++++++++++++++++++++++-------------------------- 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/VERSION b/VERSION index 077472ac..502db30a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.3-develop21 +1.18.3-develop22 diff --git a/docs/conf.py b/docs/conf.py index baeceabf..0be94587 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,11 +46,13 @@ extensions = [ 'myst_parser', 'sphinx_inline_tabs', 'sphinx_copybutton', - 'sphinx_reredirects' + 'sphinx_reredirects', + 'sphinx_design' ] source_suffix = ['.rst', '.md'] myst_heading_anchors = 4 +myst_enable_extensions = ["colon_fence"] # -- Napoleon Settings ----------------------------------------------------- napoleon_google_docstring = True @@ -545,7 +547,7 @@ html_static_path = ["_static"] html_css_files = [ "custom.css", - "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" + "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" ] def setup(app): diff --git a/modules/meta.py b/modules/meta.py index 733a29d8..e81a4bba 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -377,39 +377,35 @@ class DataFile: for var_key, var_value in condition.items(): if var_key == "value": continue + error_text = "" var_key = replace_var(var_key, [variables, default]) var_value = replace_var(var_value, [variables, default]) if var_key.endswith(".exists"): - var_value = util.parse(self.data_type, var_key, var_value, datatype="bool", default=False) - if (not var_value and var_key[:-7] in variables and variables[var_key[:-7]]) or (var_value and (var_key[:-7] not in variables or not variables[var_key[:-7]])): - logger.trace(f"Condition {i} Failed: {var_key}: {'true does not exist' if var_value else 'false exists'}") - condition_passed = False + con_value = util.parse(self.data_type, var_key, var_value, datatype="bool", default=False) + if con_value: + if var_key[:-7] not in variables or not variables[var_key[:-7]]: + error_text = "- does not exist" + elif var_key[:-7] in variables and variables[var_key[:-7]]: + error_text = "- exists" elif var_key.endswith(".not"): - if (isinstance(var_value, list) and variables[var_key[:-4]] in var_value) or \ - (not isinstance(var_value, list) and str(variables[var_key[:-4]]) == str(var_value)): + if var_key[:-4] in variables: + con_value = variables[var_key[:-4]] if isinstance(var_value, list): - logger.trace(f'Condition {i} Failed: {var_key[:-4]} "{variables[var_key[:-4]]}" in {var_value}') - else: - logger.trace(f'Condition {i} Failed: {var_key[:-4]} "{variables[var_key[:-4]]}" is "{var_value}"') - condition_passed = False - elif var_key in variables: - if (isinstance(var_value, list) and variables[var_key] not in var_value) or \ - (not isinstance(var_value, list) and str(variables[var_key]) != str(var_value)): - if isinstance(var_value, list): - logger.trace(f'Condition {i} Failed: {var_key} "{variables[var_key]}" not in {var_value}') - else: - logger.trace(f'Condition {i} Failed: {var_key} "{variables[var_key]}" is not "{var_value}"') - condition_passed = False - elif var_key in default: - if (isinstance(var_value, list) and default[var_key] not in var_value) or \ - (not isinstance(var_value, list) and str(default[var_key]) != str(var_value)): - if isinstance(var_value, list): - logger.trace(f'Condition {i} Failed: {var_key} "{default[var_key]}" not in {var_value}') - else: - logger.trace(f'Condition {i} Failed: {var_key} "{default[var_key]}" is not "{var_value}"') - condition_passed = False + if con_value in var_value: + error_text = f'in {var_value}' + elif str(con_value) == str(var_value): + error_text = f'is "{var_value}"' + elif var_key in variables or var_key in default: + con_value = variables[var_key] if var_key in variables else default[var_key] + if isinstance(var_value, list): + if con_value not in var_value: + error_text = f'not in {var_value}' + elif str(con_value) != str(var_value): + error_text = f'is not "{var_value}"' else: - logger.trace(f"Condition {i} Failed: {var_key} is not a variable provided or a default variable") + error_text = "is not a variable provided or a default variable" + if error_text: + logger.trace(f'Condition {i} Failed: {var_key}: "{con_value}" {error_text}') condition_passed = False if condition_passed: logger.debug(f'Conditional Variable: {final_key} is "{condition["value"]}"')