diff options
Diffstat (limited to 'api/ruleset.py')
-rw-r--r-- | api/ruleset.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/api/ruleset.py b/api/ruleset.py index 3dc59f2..b42b4e9 100644 --- a/api/ruleset.py +++ b/api/ruleset.py @@ -1,6 +1,7 @@ from mergedeep import merge import json +# predefined rulesets rulesets = { "default": { "timelimit": { @@ -14,14 +15,20 @@ rulesets = { } } +# resolve ruleset from ruleset name or dict def resolve_ruleset(ruleset): + # create return variable export = {} try: + # try to parse the ruleset as json export = json.loads(ruleset) merged = dict(rulesets["default"]) + + # fill missing keys in dict merge(merged, export) export = merged except ValueError as e: + # if the ruleset is a name like 'default' or 'columns+2', read it from the predefined rulesets if ruleset in rulesets: export = rulesets[ruleset] if not export: |