forked from Sharma05/icees-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
38 lines (35 loc) · 897 Bytes
/
utils.py
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
38
def opposite(qualifier):
return {
"operator": {
">": "<=",
"<": ">=",
">=": "<",
"<=": ">",
"=": "<>",
"<>": "="
}[qualifier["operator"]],
"value": qualifier["value"]
}
def to_qualifiers(feature):
if len(feature) == 1:
k, v = list(feature.items())[0]
return {
"feature_name": k,
"feature_qualifiers": [v, opposite(v)]
}
else:
k = feature["feature_name"]
v = feature["feature_qualifier"]
return {
"feature_name": k,
"feature_qualifiers": [v, opposite(v)]
}
def to_qualifiers2(feature):
if len(feature) == 1:
k, v = list(feature.items())[0]
return {
"feature_name": k,
"feature_qualifiers": v
}
else:
return feature