Esempio n. 1
0
def main():
    args = parse_args()
    cf.use_true_colors()

    inp = [line.rstrip("\n") for line in sys.stdin.readlines()]

    if args.skip_header:
        header, inp = inp[0], inp[1:]

    data = list(parse_input(inp, args.field_separator))
    col = list(select_column(data, args.column - 1))

    col_float = list(to_float(x) for x in col)
    col_min = min(col_float)
    col_max = max(col_float)

    mid = (col_min + col_max) / 2.0
    if args.mid is not None:
        mid = args.mid

    cs = ColorScaler(col_min, mid, col_max)

    if args.skip_header:
        print(header)

    for row, val in zip(inp, col_float):
        color = cs.scale(val)
        cprint(color, row)
Esempio n. 2
0
def init(args):
    """Initialise the UI, including logging"""

    if args["--vverbose"]:
        level = "DEBUG"
    elif args["--verbose"]:
        level = "INFO"
    else:
        level = None

    global QUIET
    global VERBOSE
    QUIET = args["--quiet"]
    VERBOSE = args["--verbose"] or args["--vverbose"]

    root_logger = logging.getLogger("hark_lang")

    if not args["--no-colours"]:
        import coloredlogs

        cf.use_true_colors()
        cf.use_palette(UI_COLORS)
        cf.update_palette(UI_COLORS)
        if level:
            coloredlogs.install(
                fmt="[%(asctime)s.%(msecs)03d] %(name)-25s %(message)s",
                datefmt="%H:%M:%S",
                level=level,
                logger=root_logger,
            )
    else:
        cf.disable()
        # FIXME Logger doesn't have basicConfig
        if level:
            root_logger.basicConfig(level=level)
Esempio n. 3
0
def test_color_scaler():
    cf.use_true_colors()
    cs = ColorScaler(0, 1, 2)
    for i, color in enumerate(it.chain(cs.min_to_mid, cs.mid_to_max)):
        text = color[len("hex"):]
        end = " " if (i + 1) % 8 else "\n"
        cprint(color, text, end=end)
    def __init__(self) -> None:
        cf.use_style("solarized")
        cf.use_true_colors()

        self._token_formatting_mapping: Dict[StructlogKeywords, Callable[[
            str
        ], cf.Colorful]] = {
            StructlogKeywords.Exception: cf.bold_red,
            StructlogKeywords.Timestamp: cf.bold_yellow
            # StructlogKeywords.Message: f"{token}",
            # don't mess with level formatting, it breaks structlog console renderer
            # StructlogKeywords.Level: cf.bold,
        }
Esempio n. 5
0
def load_theme():
    try:
        theme_name = os.environ['PURE_THEME']
    except KeyError: 
        theme_name = 'tomorrow'
    finally:
        theme_path = Path(os.getcwd() + '/pure/theme/' + theme_name + '.json')
        with open(str(theme_path), 'r') as theme:
            scheme = json.load(theme)

    colorful.use_true_colors()
    colorful.use_palette(scheme)
    
    return theme_name, scheme
Esempio n. 6
0
    def printBoard(self):
        cf.use_true_colors()
        p1_str = cf.red("#")
        p2_str = cf.blue("#")
        
        print("P1 Chips: ", end='')
        p1_unplayed = list(filter(lambda x: x._pos == -1, self._players[0]._stones))
        tmpstr = ""
        for i in p1_unplayed:
            tmpstr += str(i._id) + " "
        print(cf.red(tmpstr))

        for i in reversed(range(0,4)):
            tmp = 'X'  if i in self._star_pos else ' '
            tmp2 = cf.red(str(self._board[i][0]._id)) if self._board[i][0] != None else None
            print(f"[{tmp2 if self._board[i][0] != None else tmp }]", end='')
        print("      ", end='') # Space

        for i in reversed(range(12,14)):
            tmp = 'X'  if i in self._star_pos else ' '
            tmp2 = cf.red(str(self._board[i][0]._id)) if self._board[i][0] != None else None
            print(f"[{tmp2 if self._board[i][0] != None else tmp }]", end='')
        print("")

        for i in range(4, 12):
            tmp = 'X'  if i in self._star_pos else ' '
            p1_s = cf.red(str(self._board[i][0]._id)) if self._board[i][0] != None else None
            p2_s = cf.blue(str(self._board[i][0]._id)) if self._board[i][0] != None else None
            print(f"[{(p1_s if self._board[i][0]._player == self._players[0] else p2_s) if self._board[i][0] != None  else tmp }]", end='')
        print("")
        
        for i in reversed(range(0,4)):
            tmp = 'X'  if i in self._star_pos else ' '
            tmp2 = cf.blue(str(self._board[i][1]._id)) if self._board[i][1] != None else None
            print(f"[{tmp2 if self._board[i][1] != None else tmp }]", end='')
        print("      ", end='') # Space
        for i in reversed(range(12,14)):
            tmp2 = cf.blue(str(self._board[i][1]._id)) if self._board[i][1] != None else None
            tmp = 'X'  if i in self._star_pos else ' '
            print(f"[{tmp2 if self._board[i][1] != None else tmp }]", end='')
        print("")
        print("P2 Chips: ", end='')
        p2_unplayed = list(filter(lambda x: x._pos == -1, self._players[1]._stones))
        tmpstr = ""
        for i in p2_unplayed:
            tmpstr += str(i._id) + " "
        print(cf.red(tmpstr))
def test_color():
    colorful.use_true_colors()
    colorful.use_style('monokai')

    cnames = [
        'blue', 'green', 'yellow', 'brown', 'darkGray', 'magenta', 'gray',
        'lightGray', 'lightGhostWhite', 'lightOrange', 'brownGray', 'orange',
        'ghostWhite', 'purple', 'seaGreen'
    ]

    colors = [getattr(colorful, cname) for cname in cnames]
    styles = [c.style for c in colors]
    lines = ['demo'] * 20
    colored = [
        color(line) for line, color in zip(lines, itertools.cycle(colors))
    ]
    cls = [str(line) for line in colored]
    for c in cls:
        print(c)
Esempio n. 8
0
import colorful as cf

# create a colored string using clever method translation
print(cf.bold_white('Hello World'))
# create a colored string using `str.format()`
print('{c.bold}{c.lightCoral_on_white}Hello World{c.reset}'.format(c=cf))

# nest colors
print(cf.red('red {0} red'.format(cf.white('white'))))
print(cf.red('red' + cf.white(' white ', nested=True) + 'red'))

# combine styles with strings
print(cf.bold & cf.red | 'Hello World')

# use true colors
cf.use_true_colors()

# extend default color palette
cf.update_palette({'mint': '#c5e8c8'})
print(cf.mint_on_snow('Wow, this is actually mint'))

# choose a predefined style
cf.use_style('solarized')
# print the official solarized colors
print(cf.yellow('yellow'), cf.orange('orange'),
    cf.red('red'), cf.magenta('magenta'),
    cf.violet('violet'), cf.blue('blue'),
    cf.cyan('cyan'), cf.green('green'))

# directly print with colors
cf.print('{c.bold_blue}Hello World{c.reset}')
Esempio n. 9
0
COMMAND_COLOR = Config.string('ZIMAGI_COMMAND_COLOR', 'cyan')
HEADER_COLOR = Config.string('ZIMAGI_HEADER_COLOR', 'violet')
KEY_COLOR = Config.string('ZIMAGI_KEY_COLOR', 'cyan')
VALUE_COLOR = Config.string('ZIMAGI_VALUE_COLOR', 'violet')
ENCRYPTED_COLOR = Config.string('ZIMAGI_ENCRYPTED_COLOR', 'yellow')
DYNAMIC_COLOR = Config.string('ZIMAGI_DYNAMIC_COLOR', 'magenta')
RELATION_COLOR = Config.string('ZIMAGI_RELATION_COLOR', 'green')
PREFIX_COLOR = Config.string('ZIMAGI_PREFIX_COLOR', 'magenta')
SUCCESS_COLOR = Config.string('ZIMAGI_SUCCESS_COLOR', 'green')
NOTICE_COLOR = Config.string('ZIMAGI_NOTICE_COLOR', 'cyan')
WARNING_COLOR = Config.string('ZIMAGI_WARNING_COLOR', 'orange')
ERROR_COLOR = Config.string('ZIMAGI_ERROR_COLOR', 'red')
TRACEBACK_COLOR = Config.string('ZIMAGI_TRACEBACK_COLOR', 'yellow')

colorful.use_true_colors()

if COLOR_SOLARIZED:
    colorful.use_style('solarized')

#
# Runtime configurations
#
RUNTIME_PATH = "{}.env".format(os.path.join(DATA_DIR, Config.string('ZIMAGI_RUNTIME_FILE_NAME', 'zimagi')))

DEFAULT_ENV_NAME = Config.string('ZIMAGI_DEFAULT_ENV_NAME', 'default')
DEFAULT_HOST_NAME = Config.string('ZIMAGI_DEFAULT_HOST_NAME', 'default')
DEFAULT_RUNTIME_REPO = Config.string('ZIMAGI_DEFAULT_RUNTIME_REPO', 'registry.hub.docker.com')
DEFAULT_RUNTIME_IMAGE = Config.string('ZIMAGI_DEFAULT_RUNTIME_IMAGE', 'zimagi/zimagi:latest')

MODULE_BASE_PATH = os.path.join(LIB_DIR, Config.string('ZIMAGI_MODULES_DIR', 'modules'))
Esempio n. 10
0
#!/usr/bin/env python3

import sys
import random
from uuid import uuid4
from time import sleep
from faker import Faker
import colorful as color

fake = Faker()

color.use_true_colors()
color.update_palette({'darkred': '#c11b55'})


def random_color(text):
    out = ''
    while random.randint(0, 1):
        styles = [
            'bold', 'italic', 'underlined', 'blinkslow', 'blinkrapid',
            'struckthrough'
        ]
        out += random.choice(styles)
        out += '_'
    out += random.choice(list(color.colorful.__dict__['_colorpalette'].keys()))
    if random.randint(0, 1):
        out += '_on_'
        out += random.choice(
            list(color.colorful.__dict__['_colorpalette'].keys()))
    return getattr(color, out)(text)