-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.py
67 lines (58 loc) · 1.2 KB
/
tools.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
#!/usr/bin/python
# -*- coding:utf-8 -*-
def enumerate_list(list):
return ("\n".join(map(str,list)))
# Add some item(s) to a list
def add_to_list(someI, someList):
try:
someList += someI
except:
someList.append(someI)
def random(num):
import random
a = []
for _ in range(1, num+1):
a.append(_)
return a[0]
def son():
print '爸爸'
# Read syn and ant for TestWay
def getlist(L):
if type(L) is list:
return L
elif type(L) is str:
return L.split(', ')
else:
return []
# Text attributes
ALL_ATTRIBUTES_OFF = 0
BOLD = 1
UNDERSCORE = 4
BLINK = 5
REVERSE = 7
CONCEAL = 8
# Foreground colors
BLACK_FG = 30
RED_FG = 31
GREEN_FG = 32
YELLOW_FG = 33
BLUE_FG = 34
MAGENTA_FG = 35
CYAN_FG = 36
WHITE_FG = 37
# Background colors
BLACK_BG = 40
RED_BG = 41
GREEN_BG = 42
YELLOW_BG = 43
BLUE_BG = 44
MAGENTA_BG = 45
CYAN_BG = 46
WHITE_BG = 47
# improve by using *args
def set_graphics_mode(attr1, attr2 = None, attr3 = None):
if attr2 is not None:
if attr3 is not None:
return '\033[%s;%s;%sm' % (str(attr1), str(attr2), str(attr3))
return '\033[%s;%sm' % (str(attr1), str(attr2))
return '\033[%sm' % str(attr1)