Skip to content
Snippets Groups Projects
Commit 4e71f506 authored by Christopher Spinrath's avatar Christopher Spinrath
Browse files

Support range variables

parent 075d56c6
No related branches found
No related tags found
No related merge requests found
......@@ -37,15 +37,24 @@ class Variable:
return cls.new_scalar(name, value_config)
var_type = value_config["type"]
assert var_type in ["file"], "Unsupported variable type."
assert var_type in ["file", "range"], "Unsupported variable type."
directory = pathlib.Path(value_config["directory"])
assert directory.exists() and directory.is_dir()
if var_type == "file":
directory = pathlib.Path(value_config["directory"])
assert directory.exists() and directory.is_dir()
values = list(directory.iterdir())
values = list(directory.iterdir())
if value_config.get("basename", False):
values = [v.name for v in values]
if value_config.get("basename", False):
values = [v.name for v in values]
if var_type == "range":
assert "max" in value_config, f"Missing \"max\" value for range variable \"{name}\""
upper = value_config["max"]
lower = value_config.get("min", 0)
step = value_config.get("step", 1)
values = list(range(lower, upper + 1, step))
return cls.new_multi_valued(name, values)
......
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