-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.py
48 lines (41 loc) · 1.38 KB
/
command.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
import CommandServer
modules = {}
def registerCommandModule(name, desc):
print("Register command module", name)
modules[name] = {
"description": desc
}
def Command(module=None):
global modules
def inner_cmd(func):
if module is not None:
if "cbks" not in modules[module]:
modules[module]["cbks"] = {}
modules[module]["cbks"][func.__name__] = func
print("Register func", module + ":" + func.__name__)
def inner_func():
return func()
return inner_func
return inner_cmd
def Feedback(module=None):
def inner_cmd(func):
if module is not None:
CommandServer.CommandServer.register_feedback_provider(module, func)
#if "feedbacks" not in modules[module]:
# modules[module]["feedbacks"] = []
#modules[module]["feedbacks"].append(func)
#print("Register feedback", module + ":" + func.__name__)
def inner_func(*args):
return func(*args)
return inner_func
return inner_cmd
def Init(module=None):
global modules
def inner_cmd(func):
if module is not None:
modules[module]["init"] = func
print("Register init", module + ":" + func.__name__)
def inner_func():
return func()
return inner_func
return inner_cmd