color.undye method for purging color from strings
This commit is contained in:
parent
cb94166aef
commit
20116cf69d
@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
Small code to handle colored text
|
Small code to handle colored text
|
||||||
"""
|
"""
|
||||||
|
import re
|
||||||
|
|
||||||
bold = '\033[1m'
|
bold = '\033[1m'
|
||||||
end = '\033[0m'
|
end = '\033[0m'
|
||||||
@ -37,3 +37,10 @@ def setup(enable = True):
|
|||||||
dye = _dye
|
dye = _dye
|
||||||
else:
|
else:
|
||||||
dye = _nodye
|
dye = _nodye
|
||||||
|
|
||||||
|
|
||||||
|
undye_re = re.compile('\x1b\[[;\d]*[A-Za-z]')
|
||||||
|
|
||||||
|
def undye(s):
|
||||||
|
"""Purge string s of color"""
|
||||||
|
return undye_re.sub('', s)
|
Loading…
x
Reference in New Issue
Block a user