-
Notifications
You must be signed in to change notification settings - Fork 2
/
inspector.py
44 lines (36 loc) · 1.04 KB
/
inspector.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
import inspect
import pyopencl as cl
import sys
import utils
from platform_list import PlatformList
def cliloop(obj):
stack = []
while True:
obj.enter()
max_index = obj.list()
if max_index == -1:
user_input = input("(0 for back, -1 for exit)")
else:
user_input = input("{0} (1 ~ {1}, 0 for back, -1 for exit): ".format(obj.prompt(),
max_index))
if user_input == "-1":
break
elif user_input == "0":
if len(stack) == 0:
break
else:
obj = stack.pop()
continue
try:
user_index = int(user_input)
except:
continue
if user_index <= max_index:
next_obj = obj.choose(user_index - 1)
if next_obj is not None:
stack.append(obj);
obj = next_obj
def main():
cliloop(PlatformList())
if __name__ == '__main__':
main()