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

Unified Diff: third_party/colorama/ansi.py

Issue 10202010: Remove E1101 errors generated by colorama.AnsiCodes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 8 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 | « pylintrc ('k') | no next file » | 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 7b818e19ec1bf55bb7446eae9c13374171f9a543..7f09a989ebefebffda7f7bccc4dc02cdd0513121 100644
--- a/third_party/colorama/ansi.py
+++ b/third_party/colorama/ansi.py
@@ -9,13 +9,14 @@ def code_to_chars(code):
return CSI + str(code) + 'm'
class AnsiCodes(object):
- def __init__(self, codes):
- for name in dir(codes):
- if not name.startswith('_'):
- value = getattr(codes, name)
+ def __init__(self):
+ for name in dir(self):
+ if not name.startswith('_') and name.upper() == name:
+ value = getattr(self, name)
setattr(self, name, code_to_chars(value))
-class AnsiFore:
+
+class AnsiFore(AnsiCodes):
BLACK = 30
RED = 31
GREEN = 32
@@ -26,7 +27,7 @@ class AnsiFore:
WHITE = 37
RESET = 39
-class AnsiBack:
+class AnsiBack(AnsiCodes):
BLACK = 40
RED = 41
GREEN = 42
@@ -37,13 +38,15 @@ class AnsiBack:
WHITE = 47
RESET = 49
-class AnsiStyle:
+class AnsiStyle(AnsiCodes):
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 | « pylintrc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698