Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: third_party/colorama/ansi.py

Issue 54603003: Update colorama from upstream to 5a3100113a3a. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/colorama/__init__.py ('k') | third_party/colorama/ansitowin32.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/colorama/ansi.py
diff --git a/third_party/colorama/ansi.py b/third_party/colorama/ansi.py
index 7f09a989ebefebffda7f7bccc4dc02cdd0513121..5dfe374ceb58fbf0a2d4da9160bef06a27d470ac 100644
--- a/third_party/colorama/ansi.py
+++ b/third_party/colorama/ansi.py
@@ -1,3 +1,4 @@
+# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
'''
This module generates ANSI character codes to printing colors to terminals.
See: http://en.wikipedia.org/wiki/ANSI_escape_code
@@ -9,14 +10,13 @@ def code_to_chars(code):
return CSI + str(code) + 'm'
class AnsiCodes(object):
- def __init__(self):
- for name in dir(self):
- if not name.startswith('_') and name.upper() == name:
- value = getattr(self, name)
+ def __init__(self, codes):
+ for name in dir(codes):
+ if not name.startswith('_'):
+ value = getattr(codes, name)
setattr(self, name, code_to_chars(value))
-
-class AnsiFore(AnsiCodes):
+class AnsiFore:
BLACK = 30
RED = 31
GREEN = 32
@@ -27,7 +27,7 @@ class AnsiFore(AnsiCodes):
WHITE = 37
RESET = 39
-class AnsiBack(AnsiCodes):
+class AnsiBack:
BLACK = 40
RED = 41
GREEN = 42
@@ -38,15 +38,13 @@ class AnsiBack(AnsiCodes):
WHITE = 47
RESET = 49
-class AnsiStyle(AnsiCodes):
+class AnsiStyle:
BRIGHT = 1
DIM = 2
NORMAL = 22
RESET_ALL = 0
+Fore = AnsiCodes( AnsiFore )
+Back = AnsiCodes( AnsiBack )
+Style = AnsiCodes( AnsiStyle )
-# Constructing the object converts the code into the equivalent ANSI escape
-# string.
-Fore = AnsiFore()
-Back = AnsiBack()
-Style = AnsiStyle()
« no previous file with comments | « third_party/colorama/__init__.py ('k') | third_party/colorama/ansitowin32.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698