"""
import itertools
+import sys
ESC = chr(0x1B)
RESET = "0"
self._cmap[string] = self._colourIter.next()
return self._cmap[string]
+def cmdReset():
+ ''' Returns the ansi cmd colour for a RESET '''
+ if sys.stdout.isatty():
+ return ESC + "[0m"
+ else:
+ return ""
+
def cmdColour(colour):
'''
Return the ansi cmd colour (i.e. escape sequence)
for the ansi `colour` value
'''
- return ESC + "[" + colour + "m"
-
-def cmdReset():
- ''' Returns the ansi cmd colour for a RESET '''
- return cmdColour(RESET)
+ if sys.stdout.isatty():
+ return ESC + "[" + colour + "m"
+ else:
+ return ""
def cmdColourNamed(colour):
''' Return the ansi cmdColour for a given named `colour` '''