Fix Python 3.12 SyntaxWarning

SyntaxWarning: invalid escape sequence
This commit is contained in:
Jip-Hop 2024-06-29 16:43:17 +02:00
parent 01e1156832
commit 21efe90062
1 changed files with 2 additions and 2 deletions

View File

@ -174,7 +174,7 @@ class KeyValueParser(configparser.ConfigParser):
# Template to store comments as key value pair # Template to store comments as key value pair
self._comment_template = "#{0} " + delimiter + " {1}" self._comment_template = "#{0} " + delimiter + " {1}"
# Regex to match the comment prefix # Regex to match the comment prefix
self._comment_regex = re.compile(f"^#\d+\s*{re.escape(delimiter)}[^\S\n]*") self._comment_regex = re.compile(r"^#\d+\s*" + re.escape(delimiter) + r"[^\S\n]*")
# Regex to match cosmetic newlines (skips newlines in multiline values): # Regex to match cosmetic newlines (skips newlines in multiline values):
# consecutive whitespace from start of line followed by a line not starting with whitespace # consecutive whitespace from start of line followed by a line not starting with whitespace
self._cosmetic_newlines_regex = re.compile(r"^(\s+)(?=^\S)", re.MULTILINE) self._cosmetic_newlines_regex = re.compile(r"^(\s+)(?=^\S)", re.MULTILINE)
@ -538,7 +538,7 @@ def systemd_escape_path(path):
""" """
return "".join( return "".join(
map( map(
lambda char: "\s" if char == " " else "\\\\" if char == "\\" else char, path lambda char: r"\s" if char == " " else "\\\\" if char == "\\" else char, path
) )
) )