From 2dc4dd1e1a7d40edbea6fb2e7edd932a51687b21 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Wed, 8 Jan 2025 05:15:55 -0800 Subject: [PATCH] Fixed W605 (invalid-escape-sequence) --- tools/readable_bash.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/readable_bash.py b/tools/readable_bash.py index 85bbaeb0..52faf9d7 100644 --- a/tools/readable_bash.py +++ b/tools/readable_bash.py @@ -226,7 +226,7 @@ class EditConf(Grammar): options = [] eq = "=" if self[3] and "-s" in self[3].string: eq = " " - for opt in re.split("\s+", self[4].string): + for opt in re.split(r"\s+", self[4].string): k, v = opt.split("=", 1) v = re.sub(r"\n+", "", fixup_tokens(v)) # not sure why newlines are getting doubled options.append(f"{k}{eq}{v}") @@ -248,7 +248,7 @@ class EchoPipe(Grammar): grammar = OPTIONAL(SPACE), L("echo "), REST_OF_LINE, L(' | '), REST_OF_LINE, EOL def value(self): text = " ".join(f"\"{s}\"" for s in self[2].string.split(" ")) - return "
echo " + recode_bash(text) + " \
| " + recode_bash(self[4].string) + "
\n" + return "
echo " + recode_bash(text) + r" \
| " + recode_bash(self[4].string) + "
\n" def shell_line(bash): return "
" + recode_bash(bash.strip()) + "
\n" @@ -363,7 +363,7 @@ def quasitokenize(bashscript): newscript += c # "<< EOF" escaping. - if quote_mode is None and re.search("<<\s*EOF\n$", newscript): + if quote_mode is None and re.search("<<\\s*EOF\n$", newscript): quote_mode = "EOF" elif quote_mode == "EOF" and re.search("\nEOF\n$", newscript): quote_mode = None @@ -406,7 +406,7 @@ class BashScript(Grammar): # tokenize string = re.sub(".* #NODOC\n", "", string) - string = re.sub("\n\s*if .*then.*|\n\s*fi|\n\s*else|\n\s*elif .*", "", string) + string = re.sub("\n\\s*if .*then.*|\n\\s*fi|\n\\s*else|\n\\s*elif .*", "", string) string = quasitokenize(string) string = re.sub(r"hide_output ", "", string) @@ -458,7 +458,7 @@ class BashScript(Grammar): v = fixup_tokens(v) v = v.replace("\n
", "")
-		v = re.sub("
([\w\W]*?)
", lambda m : "
" + strip_indent(m.group(1)) + "
", v) + v = re.sub(r"
([\w\W]*?)
", lambda m : "
" + strip_indent(m.group(1)) + "
", v) v = re.sub(r"(\$?)PRIMARY_HOSTNAME", r"box.yourdomain.com", v) v = re.sub(r"\$STORAGE_ROOT", r"$STORE", v) @@ -468,7 +468,7 @@ class BashScript(Grammar): def wrap_lines(text, cols=60): ret = "" - words = re.split("(\s+)", text) + words = re.split(r"(\s+)", text) linelen = 0 for w in words: if linelen + len(w) > cols-1: