File tree 1 file changed +9
-7
lines changed
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 26
26
colour_help = ', ' .join ([colour for colour in bcolours if colour != "ENDC" ])
27
27
28
28
29
- def get_colour (colour ):
29
+ def get_colour (colour , default = "default" ):
30
30
"""
31
31
Get the escape code sequence for a colour
32
32
"""
33
- return bcolours .get (colour , bcolours ['ENDC' ])
33
+ return bcolours .get (colour , bcolours [default ])
34
34
35
35
36
- def printcolour (text , sameline = False , colour = get_colour ( "ENDC" ) ):
36
+ def printcolour (text , sameline = False , colour = "default" ):
37
37
"""
38
38
Print color text using escape codes
39
39
"""
40
- if sameline :
41
- sep = ''
40
+ sep = '' if sameline else '\n '
41
+
42
+ # If no colour set, do not print color ESC characters
43
+ if get_colour (colour ) == get_colour ("ENDC" ):
44
+ sys .stdout .write (text + sep )
42
45
else :
43
- sep = '\n '
44
- sys .stdout .write (get_colour (colour ) + text + bcolours ["ENDC" ] + sep )
46
+ sys .stdout .write (get_colour (colour ) + text + get_colour ("ENDC" ) + sep )
45
47
46
48
47
49
def drange (start , stop , step = 1.0 , include_stop = False ):
You can’t perform that action at this time.
0 commit comments