Moved escape mechanism to a central location in serversessionhandler.
This commit is contained in:
parent
4e2dfef321
commit
6ae2ca6901
2 changed files with 12 additions and 4 deletions
|
|
@ -189,9 +189,6 @@ class ANSIParser(object):
|
||||||
if not string:
|
if not string:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
# remove hard-coded strings
|
|
||||||
string = self.strip_raw_codes(string)
|
|
||||||
|
|
||||||
# check cached parsings
|
# check cached parsings
|
||||||
global _PARSE_CACHE
|
global _PARSE_CACHE
|
||||||
cachekey = "%s-%s-%s" % (string, strip_ansi, xterm256)
|
cachekey = "%s-%s-%s" % (string, strip_ansi, xterm256)
|
||||||
|
|
@ -337,6 +334,13 @@ def parse_ansi(string, strip_ansi=False, parser=ANSI_PARSER, xterm256=False):
|
||||||
return parser.parse_ansi(string, strip_ansi=strip_ansi, xterm256=xterm256)
|
return parser.parse_ansi(string, strip_ansi=strip_ansi, xterm256=xterm256)
|
||||||
|
|
||||||
|
|
||||||
|
def strip_raw_ansi(string, parser=ANSI_PARSER):
|
||||||
|
"""
|
||||||
|
Remove raw ansi codes from string
|
||||||
|
"""
|
||||||
|
return parser.strip_raw_codes(string)
|
||||||
|
|
||||||
|
|
||||||
def raw(string):
|
def raw(string):
|
||||||
"""
|
"""
|
||||||
Escapes a string into a form which won't be colorized by the ansi parser.
|
Escapes a string into a form which won't be colorized by the ansi parser.
|
||||||
|
|
|
||||||
|
|
@ -1096,9 +1096,13 @@ class lazy_property(object):
|
||||||
obj.__dict__[self.__name__] = value
|
obj.__dict__[self.__name__] = value
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
_STRIP_ANSI = None
|
||||||
_RE_CONTROL_CHAR = re.compile('[%s]' % re.escape(''.join([unichr(c) for c in range(0,32) + range(127,160)])))
|
_RE_CONTROL_CHAR = re.compile('[%s]' % re.escape(''.join([unichr(c) for c in range(0,32) + range(127,160)])))
|
||||||
def escape_control_sequences(string):
|
def escape_control_sequences(string):
|
||||||
"""
|
"""
|
||||||
remove non-print text sequences from string.
|
remove non-print text sequences from string.
|
||||||
"""
|
"""
|
||||||
return _RE_CONTROL_CHAR.sub('', string)
|
global _STRIP_ANSI
|
||||||
|
if not _STRIP_ANSI:
|
||||||
|
from src.utils.ansi import strip_raw_ansi as _STRIP_ANSI
|
||||||
|
return _RE_CONTROL_CHAR.sub('', _STRIP_ANSI(string))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue