From fd860d613d8e77579ee03dbc6fdaa46aef73a06b Mon Sep 17 00:00:00 2001 From: Guytri KASTANE Date: Thu, 17 Oct 2024 15:15:09 +0200 Subject: [PATCH] fix SynthaxWarning for python => 3.12 --- commands/make.py | 2 +- commands/template.py | 4 ++-- src/ElementPath.py | 24 ++++++++++++------------ src/ElementTreePython3.py | 4 ++-- src/compilation.py | 2 +- src/fileEnviron.py | 4 ++-- src/logger.py | 4 ++-- src/product.py | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/commands/make.py b/commands/make.py index 39f562a..872c078 100644 --- a/commands/make.py +++ b/commands/make.py @@ -139,7 +139,7 @@ def get_nb_proc(product_info, config, make_option): if "-j" in make_option: oExpr = re.compile("-j[0-9]+") found = oExpr.search(make_option) - opt_nb_proc = int(re.findall('\d+', found.group())[0]) + opt_nb_proc = int(re.findall(r'\d+', found.group())[0]) new_make_option = make_option.replace(found.group(), "") nbproc = -1 diff --git a/commands/template.py b/commands/template.py index cdc1c81..3923aa7 100644 --- a/commands/template.py +++ b/commands/template.py @@ -131,7 +131,7 @@ class TemplateSettings: def get_pyconf_parameters(self): if len(self.pyconf) == 0: return [] - return re.findall("%\((?P\S[^\)]*)", self.pyconf) + return re.findall(r"%\((?P\S[^\)]*)", self.pyconf) ## # Check if the file needs to be parsed. @@ -408,7 +408,7 @@ def get_template_info(config, template_name, logger): "parameter: %s" % tsettings.file_subst, 3) retcode = 1 - reexp = tsettings.delimiter_char.replace("$", "\$") + "{(?P\S[^}]*)" + reexp = tsettings.delimiter_char.replace("$", r"\$") + r"{(?P\S[^}]*)" pathlen = len(tmpdir) + 1 for root, __, files in os.walk(tmpdir): for fic in files: diff --git a/src/ElementPath.py b/src/ElementPath.py index 8fdd9cb..abf427f 100644 --- a/src/ElementPath.py +++ b/src/ElementPath.py @@ -59,15 +59,15 @@ import re xpath_tokenizer_re = re.compile( - "(" - "'[^']*'|\"[^\"]*\"|" - "::|" - "//?|" - "\.\.|" - "\(\)|" - "[/.*:\[\]\(\)@=])|" - "((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|" - "\s+" + r"(" + r"'[^']*'|\"[^\"]*\"|" + r"::|" + r"//?|" + r"\.\.|" + r"\(\)|" + r"[/.*:\[\]\(\)@=])|" + r"((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|" + r"\s+" ) def xpath_tokenizer(pattern, namespaces=None): @@ -174,7 +174,7 @@ def prepare_predicate(next, token): if elem.get(key) == value: yield elem return select - if signature == "-" and not re.match("\-?\d+$", predicate[0]): + if signature == "-" and not re.match(r"\-?\d+$", predicate[0]): # [tag] tag = predicate[0] def select(context, result): @@ -182,7 +182,7 @@ def prepare_predicate(next, token): if elem.find(tag) is not None: yield elem return select - if signature == "-='" and not re.match("\-?\d+$", predicate[0]): + if signature == "-='" and not re.match(r"\-?\d+$", predicate[0]): # [tag='value'] tag = predicate[0] value = predicate[-1] @@ -305,4 +305,4 @@ def findtext(elem, path, default=None, namespaces=None): elem = next(iterfind(elem, path, namespaces)) return elem.text or "" except StopIteration: - return default \ No newline at end of file + return default diff --git a/src/ElementTreePython3.py b/src/ElementTreePython3.py index 74adb5d..8983629 100644 --- a/src/ElementTreePython3.py +++ b/src/ElementTreePython3.py @@ -1089,7 +1089,7 @@ def register_namespace(prefix, uri): ValueError is raised if prefix is reserved or is invalid. """ - if re.match("ns\d+$", prefix): + if re.match(r"ns\d+$", prefix): raise ValueError("Prefix format reserved for internal use") for k, v in list(_namespace_map.items()): if k == uri or v == prefix: @@ -1732,4 +1732,4 @@ try: # Element, SubElement, ParseError, TreeBuilder, XMLParser from _elementtree import * except ImportError: - pass \ No newline at end of file + pass diff --git a/src/compilation.py b/src/compilation.py index ac2a556..bb0baad 100644 --- a/src/compilation.py +++ b/src/compilation.py @@ -247,7 +247,7 @@ class Builder: return # fix libtool by replacing CC="" with hack_libtool function - hack_command='''sed -i "s%^CC=\\"\(.*\)\\"%hack_libtool() { \\n\\ + hack_command=r'''sed -i "s%^CC=\\"\(.*\)\\"%hack_libtool() { \\n\\ if test \\"\$(echo \$@ | grep -E '\\\\\\-L/usr/lib(/../lib)?(64)? ')\\" == \\\"\\\" \\n\\ then\\n\\ cmd=\\"\\1 \$@\\"\\n\\ diff --git a/src/fileEnviron.py b/src/fileEnviron.py index d2dffd2..1eda190 100644 --- a/src/fileEnviron.py +++ b/src/fileEnviron.py @@ -298,7 +298,7 @@ class TclFileEnviron(FileEnviron): if sep==os.pathsep: self.output.write('append-path %s %s\n' % (key, value)) else: - self.output.write('append-path --delim=\%c %s %s\n' % (sep, key, value)) + self.output.write(r'append-path --delim=\%c %s %s\n' % (sep, key, value)) def prepend_value(self, key, value, sep=os.pathsep): """prepend value to key using sep @@ -310,7 +310,7 @@ class TclFileEnviron(FileEnviron): if sep==os.pathsep: self.output.write('prepend-path %s %s\n' % (key, value)) else: - self.output.write('prepend-path --delim=\%c %s %s\n' % (sep, key, value)) + self.output.write(r'prepend-path --delim=\%c %s %s\n' % (sep, key, value)) class BashFileEnviron(FileEnviron): diff --git a/src/logger.py b/src/logger.py index 545ac0b..4b76e39 100755 --- a/src/logger.py +++ b/src/logger.py @@ -34,8 +34,8 @@ import xmlManager import src.debug as DBG -log_macro_command_file_expression = "^[0-9]{8}_+[0-9]{6}_+.*\.xml$" -log_all_command_file_expression = "^.*[0-9]{8}_+[0-9]{6}_+.*\.xml$" +log_macro_command_file_expression = r"^[0-9]{8}_+[0-9]{6}_+.*\.xml$" +log_all_command_file_expression = r"^.*[0-9]{8}_+[0-9]{6}_+.*\.xml$" verbose = True # cvw TODO diff --git a/src/product.py b/src/product.py index 8f49eb1..a80967e 100644 --- a/src/product.py +++ b/src/product.py @@ -33,7 +33,7 @@ AVAILABLE_VCS = ['git', 'svn', 'cvs'] CONFIG_FILENAME = "sat-config-" # trace product depends version(s) PRODUCT_FILENAME = "sat-product-" # trace product compile config -config_expression = "^config-\d+$" +config_expression = r"^config-\d+$" def get_product_config(config, product_name, with_install_dir=True): """Get the specific configuration of a product from the global configuration -- 2.39.2