Use raw strings for all regexps.

No exceptions please.
This commit is contained in:
Matthias Urlichs committed 2019-01-28 14:14:23 +01:00
1 parent bba95e9000
commit f3fdac7e5a
11 files changed
+88 -87

No files matched your search

+3 -3
View File
@@ -1014,7 +1014,7 @@ class Server(object):
def regex_replace(s, find, replace):
return re.sub(find, replace, s)
html_header_regex = re.compile("<h(?P<number>[1-6])>(?P<content>.*?)</h(?P=number)>")
html_header_regex = re.compile(r"<h(?P<number>[1-6])>(?P<content>.*?)</h(?P=number)>")
def offset_html_headers(s, offset):
def repl(match):
number = int(match.group("number"))
@@ -1026,7 +1026,7 @@ class Server(object):
return "<h{number}>{content}</h{number}>".format(number=number, content=match.group("content"))
return html_header_regex.sub(repl, s)
markdown_header_regex = re.compile("^(?P<hashs>#+)\s+(?P<content>.*)$", flags=re.MULTILINE)
markdown_header_regex = re.compile(r"^(?P<hashs>#+)\s+(?P<content>.*)$", flags=re.MULTILINE)
def offset_markdown_headers(s, offset):
def repl(match):
number = len(match.group("hashs"))
@@ -1038,7 +1038,7 @@ class Server(object):
return "{hashs} {content}".format(hashs="#" * number, content=match.group("content"))
return markdown_header_regex.sub(repl, s)
html_link_regex = re.compile("<(?P<tag>a.*?)>(?P<content>.*?)</a>")
html_link_regex = re.compile(r"<(?P<tag>a.*?)>(?P<content>.*?)</a>")
def externalize_links(text):
def repl(match):
tag = match.group("tag")
+1 -1
View File
@@ -77,7 +77,7 @@ def printerToolCommand():
if response is not None:
return response
validation_regex = re.compile("tool\d+")
validation_regex = re.compile(r"tool\d+")
tags = {"source:api", "api:printer.tool"}
+3 -3
View File
@@ -60,7 +60,7 @@ class LessImportRewrite(UrlRewriter):
name = "less_importrewrite"
patterns = {
"import_rewrite": re.compile("(@import(\s+\(.*\))?\s+)\"(.*)\";")
"import_rewrite": re.compile(r"(@import(\s+\(.*\))?\s+)\"(.*)\";")
}
def import_rewrite(self, m):
@@ -73,7 +73,7 @@ class SourceMapRewrite(UrlRewriter):
name = "sourcemap_urlrewrite"
patterns = {
"url_rewrite": re.compile("(//#\s+sourceMappingURL=)(.*)")
"url_rewrite": re.compile(r"(//#\s+sourceMappingURL=)(.*)")
}
def url_rewrite(self, m):
@@ -86,7 +86,7 @@ class SourceMapRemove(PatternRewriter):
name = "sourcemap_remove"
patterns = {
"sourcemap_remove": re.compile("(//#\s+sourceMappingURL=)(.*)")
"sourcemap_remove": re.compile(r"(//#\s+sourceMappingURL=)(.*)")
}
def sourcemap_remove(self, m):