all repos — py-vite @ f0823cf5a118874f68cb2704cbc14e42731dd0bb

the original vite, written in python

vite/hue.py (view raw)

 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
#!/usr/bin/env python

COMMANDS = {
	# Lables
	'info': (33, '[!] '),
	'que': (34, '[?] '),
	'bad': (31, '[-] '),
	'good': (32, '[+] '),
	'run': (97, '[~] '),

	# Colors
	'green': 32,
	'lightgreen': 92,
	'grey': 37,
	'black': 30,
	'red': 31,
	'lightred': 91,
	'cyan': 36,
	'lightcyan': 96,
	'blue': 34,
	'lightblue': 94,
	'purple': 35,
	'yellow': 93,
	'white': 97,
	'lightpurple': 95,
	'orange': 33,

	# Styles
	'bg': ';7',
	'bold': ';1',
	'italic': '3',
	'under': '4',
	'strike': '09',
}


def _gen(string, prefix, key):
	colored = prefix if prefix else string
	not_colored = string if prefix else ''
	return '\033[{}m{}\033[0m{}'.format(key, colored, not_colored)


for key, val in COMMANDS.items():
    value = val[0] if isinstance(val, tuple) else val
    prefix = val[1] if isinstance(val, tuple) else ''
    locals()[key] = lambda s, prefix=prefix, key=value: _gen(s, prefix, key)

__all__ = list(COMMANDS.keys())