def __init__(self):
        """ Checks if the shell supports colors """

        try:
            p = subprocess.Popen(['tput', 'colors'],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            num_colors = int(p.stdout.read())
        except (OSError, ValueError):
            num_colors = 1

        self.has_colors = False
        if num_colors > 1:
            self.has_colors = True

        self.enable_colors()

        self.COLORS = self.enumerate_colors()
def __init__ ( self ) : try : p = subprocess . Popen ( [ 'tput' , 'colors' ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) num_colors = int ( p . stdout . read ( ) ) except ( OSError , ValueError ) : num_colors = 1 self . has_colors = False if num_colors > 1 : self . has_colors = True self . enable_colors ( ) self . COLORS = self . enumerate_colors ( )
Checks if the shell supports colors