all repos — py-vite @ f2f9eb9e25dfaf46f23f5d5e9d622b58d5f68c6a

the original vite, written in python

vite/hue.py (view raw)

 1#!/usr/bin/env python
 2
 3COMMANDS = {
 4	# Lables
 5	'info': (33, '[!] '),
 6	'que': (34, '[?] '),
 7	'bad': (31, '[-] '),
 8	'good': (32, '[+] '),
 9	'run': (97, '[~] '),
10
11	# Colors
12	'green': 32,
13	'lightgreen': 92,
14	'grey': 37,
15	'black': 30,
16	'red': 31,
17	'lightred': 91,
18	'cyan': 36,
19	'lightcyan': 96,
20	'blue': 34,
21	'lightblue': 94,
22	'purple': 35,
23	'yellow': 93,
24	'white': 97,
25	'lightpurple': 95,
26	'orange': 33,
27
28	# Styles
29	'bg': ';7',
30	'bold': ';1',
31	'italic': '3',
32	'under': '4',
33	'strike': '09',
34}
35
36
37def _gen(string, prefix, key):
38	colored = prefix if prefix else string
39	not_colored = string if prefix else ''
40	return '\033[{}m{}\033[0m{}'.format(key, colored, not_colored)
41
42
43for key, val in COMMANDS.items():
44    value = val[0] if isinstance(val, tuple) else val
45    prefix = val[1] if isinstance(val, tuple) else ''
46    locals()[key] = lambda s, prefix=prefix, key=value: _gen(s, prefix, key)
47
48__all__ = list(COMMANDS.keys())