blob: 40458de217b197d635663d56eafd613cd74d2212 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
from mergedeep import merge
import json
# predefined rulesets
rulesets = {
"default": {
"timelimit": {
"enabled": False,
"minutes": 0,
"seconds": 0,
"addmove": 0,
"shared": False,
},
"ranked": True,
}
}
# 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:
export = rulesets["default"]
return export
|