summaryrefslogtreecommitdiffstats
path: root/pyload/lib/colorlog/escape_codes.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2013-11-16 22:31:35 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2013-11-16 22:31:35 +0100
commit5edf4597efba463d57039d337b3656c8fa5fea78 (patch)
tree87d58725a719824bef50041ff41d179067759648 /pyload/lib/colorlog/escape_codes.py
parentFixed logfile color codes (colorize console only) + settable color log type +... (diff)
downloadpyload-5edf4597efba463d57039d337b3656c8fa5fea78.tar.xz
Applied RaNaN advice
Diffstat (limited to 'pyload/lib/colorlog/escape_codes.py')
-rw-r--r--pyload/lib/colorlog/escape_codes.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/pyload/lib/colorlog/escape_codes.py b/pyload/lib/colorlog/escape_codes.py
new file mode 100644
index 000000000..8d057e9e4
--- /dev/null
+++ b/pyload/lib/colorlog/escape_codes.py
@@ -0,0 +1,37 @@
+"""
+Generates a dictionary of ANSI escape codes
+
+http://en.wikipedia.org/wiki/ANSI_escape_code
+"""
+
+__all__ = ['escape_codes']
+
+# Returns escape codes from format codes
+esc = lambda *x: '\033[' + ';'.join(x) + 'm'
+
+# The initial list of escape codes
+escape_codes = {
+ 'reset': esc('39', '49', '0'),
+ 'bold': esc('01'),
+}
+
+# The color names
+colors = [
+ 'black',
+ 'red',
+ 'green',
+ 'yellow',
+ 'blue',
+ 'purple',
+ 'cyan',
+ 'white'
+]
+
+# Create foreground and background colors...
+for lcode, lname in [('3', ''), ('4', 'bg_')]:
+ # ...with the list of colors...
+ for code, name in enumerate(colors):
+ code = str(code)
+ # ...and both normal and bold versions of each color
+ escape_codes[lname + name] = esc(lcode + code)
+ escape_codes[lname + "bold_" + name] = esc(lcode + code, "01")