-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.py
24 lines (20 loc) · 846 Bytes
/
common.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
### Common methods shared by all files
class C:
def __init__(self, session):
self.session = session
def CYAN(self, str):
return "%s%s%s" % (self.session.CYAN,str,self.session.RESET)
def B_WHITE(self, str):
return "%s%s%s%s" % (self.session.BOLD,self.session.WHITE,str,self.session.RESET)
def B_RED(self, str):
return "%s%s%s%s" % (self.session.BOLD,self.session.RED,str,self.session.RESET)
def B_GREEN(self, str):
return "%s%s%s%s" % (self.session.BOLD,self.session.GREEN,str,self.session.RESET)
def flatten(self, x):
result = []
for el in x:
if hasattr(el, "__iter__") and not isinstance(el, basestring):
result.extend(self.flatten(el))
else:
result.append(el)
return result