/usr/lib/python2.7/dist-packages/pyvows/color.py is in python-pyvows 2.1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | # -*- coding: utf-8 -*-
'''PyVows' support for color-printing to the terminal.
Currently, just a thin wrapper around the (3rd-party) `colorama`
module.
'''
# pyvows testing engine
# https://github.com/heynemann/pyvows
# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 Bernardo Heynemann heynemann@gmail.com
try:
from colorama import init, Fore, Style
init(autoreset=True)
except ImportError:
class NoColor(object):
'''When Python can't import `colorama`, this stand-in class prevents
other parts of PyVows from throwing errors when attempting to print
in color.
'''
def __getattr__(self, *args, **kwargs):
return ''
Fore = NoColor()
Style = NoColor()
#-------------------------------------------------------------------------------------------------
__all__ = [
'Fore', 'Style',
'BLACK', 'BLUE', 'CYAN', 'GREEN', 'RED', 'YELLOW', 'WHITE', 'RESET', 'RESET_ALL',
'black', 'blue', 'cyan', 'green', 'red', 'yellow', 'white', 'bold', 'dim'
]
#-------------------------------------------------------------------------------------------------
# Color Constants
#-------------------------------------------------------------------------------------------------
BLACK = Fore.BLACK
BLUE = Fore.BLUE
CYAN = Fore.CYAN
GREEN = Fore.GREEN
RED = Fore.RED
YELLOW = Fore.YELLOW
WHITE = Fore.WHITE
#
BOLD = Style.BRIGHT
DIM = Style.DIM
#
RESET = Fore.RESET
RESET_ALL = Style.RESET_ALL
#-------------------------------------------------------------------------------------------------
# Functions
#-------------------------------------------------------------------------------------------------
def _colorize(msg, color, reset=True):
reset = RESET if reset else ''
return '{COLOR}{0!s}{RESET}'.format(msg, COLOR=color, RESET=reset)
def _bold(msg):
return '{BOLD}{0!s}{RESET_ALL}'.format(msg, BOLD=BOLD, RESET_ALL=RESET_ALL)
def _dim(msg):
return '{DIM}{0!s}{RESET_ALL}'.format(msg, DIM=DIM, RESET_ALL=RESET_ALL)
black = lambda msg: _colorize(msg, BLACK)
blue = lambda msg: _colorize(msg, BLUE)
cyan = lambda msg: _colorize(msg, CYAN)
green = lambda msg: _colorize(msg, GREEN)
red = lambda msg: _colorize(msg, RED)
yellow = lambda msg: _colorize(msg, YELLOW)
white = lambda msg: _colorize(msg, WHITE)
bold = lambda msg: _bold(msg)
dim = lambda msg: _dim(msg)
|