diff options
Diffstat (limited to 'src/Utils.py')
| -rw-r--r-- | src/Utils.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Utils.py b/src/Utils.py index e87330c2..ebf82f82 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -155,6 +155,7 @@ COLOR_LIGHTBLUE, COLOR_PINK, COLOR_GREY, COLOR_LIGHTGREY = (12, 13, FONT_BOLD, FONT_ITALIC, FONT_UNDERLINE, FONT_INVERT = ("\x02", "\x1D", "\x1F", "\x16") FONT_COLOR, FONT_RESET = "\x03", "\x0F" +REGEX_COLOR = re.compile("%s\d\d(?:,\d\d)?" % FONT_COLOR) def color(s, foreground, background=None): foreground = str(foreground).zfill(2) @@ -169,6 +170,13 @@ def bold(s): def underline(s): return "%s%s%s" % (FONT_UNDERLINE, s, FONT_UNDERLINE) +def strip_font(s): + s = s.replace(FONT_BOLD, "") + s = s.replace(FONT_ITALIC, "") + s = REGEX_COLOR.sub("", s) + s = s.replace(FONT_COLOR, "") + return s + TIME_SECOND = 1 TIME_MINUTE = TIME_SECOND*60 TIME_HOUR = TIME_MINUTE*60 |
