summaryrefslogtreecommitdiff
path: root/lib/spack/llnl/util/tty/color.py
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-12-02 21:56:22 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2014-12-02 22:32:15 -0800
commit11cffff943b04ce69692db973c48de29647c8087 (patch)
tree5b4274458fc5584a9c536735009629a864542060 /lib/spack/llnl/util/tty/color.py
parent40b4fa544362d2942ef7663c7fc809c1f5ef591b (diff)
downloadspack-11cffff943b04ce69692db973c48de29647c8087.tar.gz
spack-11cffff943b04ce69692db973c48de29647c8087.tar.bz2
spack-11cffff943b04ce69692db973c48de29647c8087.tar.xz
spack-11cffff943b04ce69692db973c48de29647c8087.zip
colify handles ansi color input directly; no more decorator.
Diffstat (limited to 'lib/spack/llnl/util/tty/color.py')
-rw-r--r--lib/spack/llnl/util/tty/color.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/spack/llnl/util/tty/color.py b/lib/spack/llnl/util/tty/color.py
index 14974a1014..598e9d44f5 100644
--- a/lib/spack/llnl/util/tty/color.py
+++ b/lib/spack/llnl/util/tty/color.py
@@ -149,6 +149,11 @@ def colorize(string, **kwargs):
return re.sub(color_re, match_to_ansi(color), string)
+def clen(string):
+ """Return the length of a string, excluding ansi color sequences."""
+ return len(re.sub(r'\033[^m]*m', '', string))
+
+
def cwrite(string, stream=sys.stdout, color=None):
"""Replace all color expressions in string with ANSI control
codes and write the result to the stream. If color is