-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
98 lines (75 loc) · 2.1 KB
/
config.py
File metadata and controls
98 lines (75 loc) · 2.1 KB
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 os
import time
import glob
import subprocess
import collections as cl
from defines import *
set_task_path("task")
num_tasks = 50
time_wait = 15
time_starve = 15
max_busy = 5
max_recv = 15
unique_busy = True
ts_format = "%H:%M:%S"
rt_format = "%H:%M:%S"
colors = "034", "056", "142", "126", "117", "088", "022", "069", "053", "181"
recv_free = "070"
recv_mine = "178"
recv_dead = "124"
defaults = [
( "param1" , "a" ),
( "-param2" , 1 ),
( "-param3" , 1.0 ),
( "-param4" , [ "a", 1, 1.0 ] ),
( "-param5" , ENABLE ),
( "-param6" , "fixed" ),
( "-param7" , "1" )
]
tests = [(
( "param1" , [ "a", "b", "c", "d", "e" ] ),
( "-param2" , [ 1, 2, 3, 4, 5 ] ),
( "-param3" , [ 1.0, 1.1, 1.2, 1.3, 1.4 ] ),
( "-param4" , [ [ 1, 2, 3 ], [ "a", "b", "c" ], [ 1, "a", False ] ] ),
( "-param5" , [ ENABLE, DISABLE ] ),
( "-param7" , [ "1", "2", "3" ] ),
), (
( "param1" , [ "e", "f", "g", "h" ] ),
( "-param2" , [ 1, 2, 3, 4, 5 ] ),
( "-param3" , [ 1.0, 1.5, 2.0, 2.5, 3.0 ] ),
( "-param4" , [ [ 1, 2, 3 ], [ "a", "b", "c" ], [ 1, "a", True ] ] ),
( "-param5" , [ ENABLE, DISABLE ] ),
( "-param7" , [ "1", "2", "4" ] ),
)]
def expand (flags):
if flags["param1"] == "e" and flags["-param5"] == DISABLE:
return
yield flags
def preprocess (key, val):
return key, val
def log_format (key, val):
if key == "-param7":
yield "{}={}".format(key, val)
elif val is ENABLE:
yield key
elif val is DISABLE:
yield "[{}]".format(key)
else:
yield "{}: {}".format(key, val)
def param_format (key, val):
if val is not DISABLE:
if key == "-param7":
yield "{}={}".format(key, val)
else:
if key[0] == "-":
yield key
if isinstance(val, list):
for v in val:
yield str(v)
elif val is not ENABLE:
yield str(val)
def run (wid, data, pos):
print(*(
param for key, val in data.items() for param in param_format(key, val)
))
time.sleep(0.1)