Skip to content
Snippets Groups Projects
Commit f220495e authored by Juraj Paluba's avatar Juraj Paluba
Browse files

Merge branch 'develop'

parents 3255ec69 fadab68b
No related branches found
No related tags found
1 merge request!12Merge develop to master
Checking pipeline status
from typing import List
import yaml
from generator.var_object import Variable
def get_variables(variables_raw: dict) -> List[Variable]:
var_objects = []
for variable_name, variable_options in variables_raw.items():
v_type = variable_options["type"]
v_min = variable_options.get("min")
v_max = variable_options.get("max")
v_length = variable_options.get("length")
v_prohibited = variable_options.get("prohibited")
if v_prohibited is None:
v_prohibited = []
var_objects.append(Variable(variable_name, v_type, v_min, v_max, v_prohibited, v_length))
return var_objects
def parser_var_file(var_file):
"""
Main function to parsen source data stored in file.
......@@ -19,20 +36,9 @@ def parser_var_file(var_file):
"""
try:
var_list = yaml.load(var_file, Loader=yaml.FullLoader)
var_objects = []
for var in var_list.keys():
v_name = var
v_type = var_list[var]["type"]
v_min = var_list[var].get("min")
v_max = var_list[var].get("max")
v_length = var_list[var].get("length")
v_prohibited = var_list[var].get("prohibited")
if v_prohibited is None:
v_prohibited = []
var_objects.append(Variable(v_name, v_type, v_min, v_max, v_prohibited, v_length))
except Exception as e:
print("Error occure")
variables_raw = yaml.load(var_file, Loader=yaml.FullLoader)
return get_variables(variables_raw)
except Exception as exc:
# TODO: Remove this horrendous exception handling!
print(f"Something went wrong: {exc}")
return None
return var_objects
[metadata]
version = v0.1.0rc1
version = v0.1.2
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment