aboutsummaryrefslogtreecommitdiff
path: root/api/ruleset.py
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-03-28 12:19:28 +0200
committerlonkaars <l.leblansch@gmail.com>2021-03-28 12:19:28 +0200
commit2f4536d6b08b69168ebf3e718cbd8e3002b9af5a (patch)
tree5307692fb341d7f924ee9b73f3751e7e56cfb192 /api/ruleset.py
parent1f897d3f5ad11178cf4776ae4070c9d3e832f5f3 (diff)
added comments
Diffstat (limited to 'api/ruleset.py')
-rw-r--r--api/ruleset.py7
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: