scripts/release/util.py
changeset 1833 9df2e9a67081
parent 1827 c03995a6a88e
child 1835 3f30b7b14c57
--- a/scripts/release/util.py	Fri Mar 13 16:56:56 2009 +0000
+++ b/scripts/release/util.py	Fri Mar 13 18:14:44 2009 +0000
@@ -26,6 +26,7 @@
     ]
 
 import os.path
+import re
 import subprocess
 
 import error
@@ -43,6 +44,7 @@
 # configure fore/background colors and other basic text display
 # settings.
 _ANSI_ESCAPE = '\x1b[%dm'
+_ANSI_ESCAPE_RE = re.compile(r'\x1b\[\d+m')
 
 
 # Some internal non-color settings that we use.
@@ -82,6 +84,11 @@
                          text, _ansi_escape(_RESET))
 
 
+def decolorize(text):
+    """Remove ANSI color codes from text."""
+    return _ANSI_ESCAPE_RE.sub('', text)
+
+
 class Paths(object):
     """A helper to construct and check paths under a given root."""