diff sat/tools/common/regex.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children 003b8b4b56a7
line wrap: on
line diff
--- a/sat/tools/common/regex.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat/tools/common/regex.py	Wed Jun 27 20:14:46 2018 +0200
@@ -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 @@
     """
     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 @@
     """
     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)