[22] update conditions

pull/1288/head
meisnate12 2 years ago
parent 0026e284b6
commit 9c2fd7e064

@ -1 +1 @@
1.18.3-develop21
1.18.3-develop22

@ -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):

@ -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 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 var_key[:-4] in variables:
con_value = variables[var_key[:-4]]
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"]}"')

Loading…
Cancel
Save