equal
deleted
inserted
replaced
24 # alphabetical order by last name, please |
24 # alphabetical order by last name, please |
25 '"David Anderson" <dave@natulte.net>', |
25 '"David Anderson" <dave@natulte.net>', |
26 ] |
26 ] |
27 |
27 |
28 import os.path |
28 import os.path |
|
29 import re |
29 import subprocess |
30 import subprocess |
30 |
31 |
31 import error |
32 import error |
32 |
33 |
33 |
34 |
41 |
42 |
42 # The magic escape sequence understood by modern terminal emulators to |
43 # The magic escape sequence understood by modern terminal emulators to |
43 # configure fore/background colors and other basic text display |
44 # configure fore/background colors and other basic text display |
44 # settings. |
45 # settings. |
45 _ANSI_ESCAPE = '\x1b[%dm' |
46 _ANSI_ESCAPE = '\x1b[%dm' |
|
47 _ANSI_ESCAPE_RE = re.compile(r'\x1b\[\d+m') |
46 |
48 |
47 |
49 |
48 # Some internal non-color settings that we use. |
50 # Some internal non-color settings that we use. |
49 _RESET = 0 # Reset to terminal defaults. |
51 _RESET = 0 # Reset to terminal defaults. |
50 _BOLD = 1 # Brighter colors. |
52 _BOLD = 1 # Brighter colors. |
78 text. |
80 text. |
79 """ |
81 """ |
80 bold = _ansi_escape(_BOLD) if bold else '' |
82 bold = _ansi_escape(_BOLD) if bold else '' |
81 return '%s%s%s%s' % (bold, _ansi_escape(color), |
83 return '%s%s%s%s' % (bold, _ansi_escape(color), |
82 text, _ansi_escape(_RESET)) |
84 text, _ansi_escape(_RESET)) |
|
85 |
|
86 |
|
87 def decolorize(text): |
|
88 """Remove ANSI color codes from text.""" |
|
89 return _ANSI_ESCAPE_RE.sub('', text) |
83 |
90 |
84 |
91 |
85 class Paths(object): |
92 class Paths(object): |
86 """A helper to construct and check paths under a given root.""" |
93 """A helper to construct and check paths under a given root.""" |
87 |
94 |