mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
tools: Fix regex syntax warnings with Python 3.12
Since Python 3.12, invalid escape sequences generate SyntaxWarning. In the future, these invalid sequences will raise a SyntaxError, so changed to using raw string notation. Link: https://docs.python.org/3/whatsnew/3.12.html#other-language-changes Fixes:d8f3a67bf9("pygrub: further improve grub2 support") Fixes:dd03048708("xen/pygrub: grub2/grub.cfg from RHEL 7 has new commands in menuentry") Fixes:d1b93ea261("tools/pygrub: Make pygrub understand default entry in string format") Fixes:622e368758("Add ZFS libfsimage support patch") Fixes:02b26c02c7("xen/scripts: add cppcheck tool to the xen-analysis.py script") Fixes:56c0063f4e("xen/misra: xen-analysis.py: Improve the cppcheck version check") Signed-off-by: Ariel Otilibili <Ariel.Otilibili-Anieli@eurecom.fr> Reviewed-by: Luca Fancellu <luca.fancellu@arm.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
1 parent
f9a2e86f21
commit
826a9eb072
3 files changed
+7
-7
No files matched your search
@@ -320,7 +320,7 @@ class GrubConfigFile(_GrubConfigFile):
|
|||||||
def grub2_handle_set(arg):
|
def grub2_handle_set(arg):
|
||||||
(com,arg) = grub_split(arg,2)
|
(com,arg) = grub_split(arg,2)
|
||||||
com="set:" + com
|
com="set:" + com
|
||||||
m = re.match("([\"\'])(.*)\\1", arg)
|
m = re.match(r"([\"\'])(.*)\1", arg)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
arg=m.group(2)
|
arg=m.group(2)
|
||||||
return (com,arg)
|
return (com,arg)
|
||||||
@@ -402,7 +402,7 @@ class Grub2ConfigFile(_GrubConfigFile):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# new image
|
# new image
|
||||||
title_match = re.match('^menuentry ["\'](.*?)["\'] (.*){', l)
|
title_match = re.match(r'^menuentry ["\'](.*?)["\'] (.*){', l)
|
||||||
if title_match:
|
if title_match:
|
||||||
if img is not None:
|
if img is not None:
|
||||||
raise RuntimeError("syntax error: cannot nest menuentry (%d %s)" % (len(img),img))
|
raise RuntimeError("syntax error: cannot nest menuentry (%d %s)" % (len(img),img))
|
||||||
|
|||||||
@@ -614,7 +614,7 @@ class Grub:
|
|||||||
title = self.cf.default
|
title = self.cf.default
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
title = re.search('(\S)>(\S.+$)',title).group(2)
|
title = re.search(r'(\S)>(\S.+$)',title).group(2)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -1039,7 +1039,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# if boot filesystem is set then pass to fsimage.open
|
# if boot filesystem is set then pass to fsimage.open
|
||||||
bootfsargs = '"%s"' % incfg["args"]
|
bootfsargs = '"%s"' % incfg["args"]
|
||||||
bootfsgroup = re.findall('zfs-bootfs=(.*?)[\s\,\"]', bootfsargs)
|
bootfsgroup = re.findall(r'zfs-bootfs=(.*?)[\s\,\"]', bootfsargs)
|
||||||
if bootfsgroup:
|
if bootfsgroup:
|
||||||
bootfsoptions = bootfsgroup[0]
|
bootfsoptions = bootfsgroup[0]
|
||||||
else:
|
else:
|
||||||
@@ -1104,7 +1104,7 @@ if __name__ == "__main__":
|
|||||||
if chosencfg["args"]:
|
if chosencfg["args"]:
|
||||||
zfsinfo = xenfsimage.getbootstring(fs)
|
zfsinfo = xenfsimage.getbootstring(fs)
|
||||||
if zfsinfo is not None:
|
if zfsinfo is not None:
|
||||||
e = re.compile("zfs-bootfs=[\w\-\.\:@/]+" )
|
e = re.compile(r"zfs-bootfs=[\w\-.:@/]+" )
|
||||||
(chosencfg["args"],count) = e.subn(zfsinfo, chosencfg["args"])
|
(chosencfg["args"],count) = e.subn(zfsinfo, chosencfg["args"])
|
||||||
if count == 0:
|
if count == 0:
|
||||||
chosencfg["args"] += " -B %s" % zfsinfo
|
chosencfg["args"] += " -B %s" % zfsinfo
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ def __generate_suppression_list(out_file):
|
|||||||
# start of a comment '/*'
|
# start of a comment '/*'
|
||||||
comment_line_starts = re.match('^[ \t]*/\*.*$', line)
|
comment_line_starts = re.match('^[ \t]*/\*.*$', line)
|
||||||
# Matches a line with text and the end of a comment '*/'
|
# Matches a line with text and the end of a comment '*/'
|
||||||
comment_line_stops = re.match('^.*\*/$', line)
|
comment_line_stops = re.match(r'^.*\*/$', line)
|
||||||
if (not comment_section) and comment_line_starts:
|
if (not comment_section) and comment_line_starts:
|
||||||
comment_section = True
|
comment_section = True
|
||||||
if (len(line.strip()) != 0) and (not comment_section):
|
if (len(line.strip()) != 0) and (not comment_section):
|
||||||
@@ -157,7 +157,7 @@ def generate_cppcheck_deps():
|
|||||||
"Error occured retrieving cppcheck version:\n{}\n\n{}"
|
"Error occured retrieving cppcheck version:\n{}\n\n{}"
|
||||||
)
|
)
|
||||||
|
|
||||||
version_regex = re.search('^Cppcheck (\d+)\.(\d+)(?:\.\d+)?$',
|
version_regex = re.search(r'^Cppcheck (\d+)\.(\d+)(?:\.\d+)?$',
|
||||||
invoke_cppcheck, flags=re.M)
|
invoke_cppcheck, flags=re.M)
|
||||||
# Currently, only cppcheck version >= 2.7 is supported, but version 2.8 is
|
# Currently, only cppcheck version >= 2.7 is supported, but version 2.8 is
|
||||||
# known to be broken, please refer to docs/misra/cppcheck.txt
|
# known to be broken, please refer to docs/misra/cppcheck.txt
|
||||||
|
|||||||