Package lib :: Module ansi
[hide private]
[frames] | no frames]

Module ansi

source code

Module containing ANSI escape sequences and helper functions for colour terminal output.

Functions [hide private]
bool
enable_control_chars(stream=1)
Helper function for determining if control characters should be printed to the IO streams.
source code
Variables [hide private]
  relax_prompt = '\x1b[94m'
  relax_error = '\x1b[31m'
  relax_warning = '\x1b[33m'
  script = '\x1b[36m'
  end = '\x1b[0m'
  __package__ = 'lib'

Imports: ctypes, sys


Function Details [hide private]

enable_control_chars(stream=1)

source code 

Helper function for determining if control characters should be printed to the IO streams.

This uses both the sys.std*.isatty() methods as well as the operating system. Control characters are only shown on GNU/Linux and Mac OS X (or technically they are disabled on MS Windows as both cmd and the PowerShell do not support the ANSI characters).

Parameters:
  • stream (int) - The stream to check. The value of 0 corresponds to STDIN, 1 corresponds to STDOUT, and 2 corresponds to STDERR.
Returns: bool
The answer of whether color and other control characters should be printed.