-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.py
98 lines (86 loc) · 3.01 KB
/
storage.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import Range # type: ignore
class Storage():
def __init__(self):
self.functions = {
'functions': {
'content': self.ListFunctions,
}
}
self.chargeFunctions = []
self.serverClients = []
self.directions = {
"X": [1.0,0.0,0.0],
"-X": [-1.0,0.0,0.0],
"Y": [0.0,1.0,0.0],
"-Y": [0.0,-1.0,0.0],
"Z": [0.0,0.0,1.0],
"-Z": [0.0,0.0,-1.0],
}
self.keymapping = {
"Z": Range.events.ZKEY,
"X": Range.events.XKEY,
"C": Range.events.CKEY,
"V": Range.events.VKEY,
"B": Range.events.BKEY,
"N": Range.events.NKEY,
"M": Range.events.MKEY,
"A": Range.events.AKEY,
"S": Range.events.SKEY,
"D": Range.events.DKEY,
"F": Range.events.FKEY,
"G": Range.events.GKEY,
"H": Range.events.HKEY,
"J": Range.events.JKEY,
"K": Range.events.KKEY,
"L": Range.events.LKEY,
"Q": Range.events.QKEY,
"W": Range.events.WKEY,
"E": Range.events.EKEY,
"R": Range.events.RKEY,
"T": Range.events.TKEY,
"Y": Range.events.YKEY,
"U": Range.events.UKEY,
"I": Range.events.IKEY,
"O": Range.events.OKEY,
"P": Range.events.PKEY,
"1": Range.events.ONEKEY,
"2": Range.events.TWOKEY,
"3": Range.events.THREEKEY,
"4": Range.events.FOURKEY,
"5": Range.events.FIVEKEY,
"6": Range.events.SIXKEY,
"7": Range.events.SEVENKEY,
"8": Range.events.EIGHTKEY,
"9": Range.events.NINEKEY,
"0": Range.events.ZEROKEY,
}
def SetChargeFunction(self, function, params = None):
""" """
self.chargeFunctions.append({"function": function, "params": params})
def SetCharge(self):
""" """
if len(self.chargeFunctions) != 0:
for index, function in enumerate(self.chargeFunctions):
result = None
if "payload" in function['params']:
if function['params'].get('payload') in Range.logic.getSceneList():
result = function['function'](function['params'])
if result:
self.chargeFunctions.pop(index)
else:
return None
def ListFunctions(self) -> list:
""" """
return list(self.functions.keys())
def SetFunction(self, key: str, function) -> dict:
""" """
self.functions[key] = {
'content': function
}
return self.functions.get(key, None)
def GetFunction(self, key: str, use: bool = False) -> dict:
""" """
if use:
return self.functions.get(key, None).get('content')
else:
return self.functions.get(key, None)