code style reformatting using black
This commit is contained in:
parent
4127bcffd0
commit
744cb0c503
1 changed files with 21394 additions and 10488 deletions
|
|
@ -20,16 +20,17 @@
|
|||
""" regex tools common to backend and frontends """
|
||||
|
||||
import re
|
||||
path_escape = {'%': '%25', '/': '%2F', '\\': '%5c'}
|
||||
path_escape_rev = {re.escape(v):k for k, v in path_escape.iteritems()}
|
||||
path_escape = {re.escape(k):v for k, v in path_escape.iteritems()}
|
||||
# thanks to Martijn Pieters (https://stackoverflow.com/a/14693789)
|
||||
RE_ANSI_REMOVE = re.compile(r'\x1b[^m]*m')
|
||||
|
||||
path_escape = {"%": "%25", "/": "%2F", "\\": "%5c"}
|
||||
path_escape_rev = {re.escape(v): k for k, v in path_escape.iteritems()}
|
||||
path_escape = {re.escape(k): v for k, v in path_escape.iteritems()}
|
||||
# thanks to Martijn Pieters (https://stackoverflow.com/a/14693789)
|
||||
RE_ANSI_REMOVE = re.compile(r"\x1b[^m]*m")
|
||||
|
||||
|
||||
def reJoin(exps):
|
||||
"""Join (OR) various regexes"""
|
||||
return re.compile('|'.join(exps))
|
||||
return re.compile("|".join(exps))
|
||||
|
||||
|
||||
def reSubDict(pattern, repl_dict, string):
|
||||
|
|
@ -42,6 +43,7 @@ def reSubDict(pattern, repl_dict, string):
|
|||
"""
|
||||
return pattern.sub(lambda m: repl_dict[re.escape(m.group(0))], string)
|
||||
|
||||
|
||||
path_escape_re = reJoin(path_escape.keys())
|
||||
path_escape_rev_re = reJoin(path_escape_rev.keys())
|
||||
|
||||
|
|
@ -63,10 +65,11 @@ def pathUnescape(string):
|
|||
"""
|
||||
return reSubDict(path_escape_rev_re, path_escape_rev, string)
|
||||
|
||||
|
||||
def ansiRemove(string):
|
||||
"""Remove ANSI escape codes from string
|
||||
|
||||
@param string(basestr): string to filter
|
||||
@return (str, unicode): string without ANSI escape codes
|
||||
"""
|
||||
return RE_ANSI_REMOVE.sub('', string)
|
||||
return RE_ANSI_REMOVE.sub("", string)
|
||||
|
|
|
|||
Loading…
Reference in a new issue