1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
Description: Use raw strings in re.match to avoid SyntaxWarnings
SyntaxWarnings for invalid escape sequences were first introduced in Python 3.6
Author: Nick Morrott <nickm@debian.org>
Forwarded: https://github.com/project-generator/project_generator/pull/510
Last-Update: 2024-02-10
---
--- a/project_generator/tools/coide.py
+++ b/project_generator/tools/coide.py
@@ -148,7 +148,7 @@
if expanded_dic['template']:
for template in expanded_dic['template']:
template = join(getcwd(), template)
- if splitext(template)[1] == '.coproj' or re.match('.*\.coproj.tmpl$', template):
+ if splitext(template)[1] == '.coproj' or re.match(r".*\.coproj.tmpl$", template):
try:
coproj_dic = xmltodict.parse(open(template))
except IOError:
@@ -161,7 +161,7 @@
# template overrides what is set in the yaml files
for template in self.env_settings.templates['coide']:
template = join(getcwd(), template)
- if splitext(template)[1] == '.coproj' or re.match('.*\.coproj.tmpl$', template):
+ if splitext(template)[1] == '.coproj' or re.match(r".*\.coproj.tmpl$", template):
try:
coproj_dic = xmltodict.parse(open(template))
except IOError:
--- a/project_generator/tools/iar.py
+++ b/project_generator/tools/iar.py
@@ -372,14 +372,14 @@
for template in expanded_dic['template']:
template = join(getcwd(), template)
# we support .ewp or .ewp.tmpl templates
- if os.path.splitext(template)[1] == '.ewp' or re.match('.*\.ewp.tmpl$', template):
+ if os.path.splitext(template)[1] == '.ewp' or re.match(r".*\.ewp.tmpl$", template):
try:
ewp_dic = xmltodict.parse(open(template,'rb'), dict_constructor=dict)
template_ewp = True
except IOError:
logger.info("Template file %s not found" % template)
ewp_dic = xmltodict.parse(open(self.ewp_file,'rb').read())
- if os.path.splitext(template)[1] == '.ewd' or re.match('.*\.ewd.tmpl$', template):
+ if os.path.splitext(template)[1] == '.ewd' or re.match(r".*\.ewd.tmpl$", template):
try:
ewd_dic = xmltodict.parse(open(template,'rb'), dict_constructor=dict)
template_ewd = True
@@ -399,14 +399,14 @@
# template overrides what is set in the yaml files
for template in self.env_settings.templates['iar']:
template = join(getcwd(), template)
- if os.path.splitext(template)[1] == '.ewp' or re.match('.*\.ewp.tmpl$', template):
+ if os.path.splitext(template)[1] == '.ewp' or re.match(r".*\.ewp.tmpl$", template):
try:
ewp_dic = xmltodict.parse(open(template,'rb'), dict_constructor=dict)
template_ewp = True
except IOError:
logger.info("Template file %s not found" % template)
ewp_dic = xmltodict.parse(open(self.ewp_file,'rb').read())
- if os.path.splitext(template)[1] == '.ewd' or re.match('.*\.ewd.tmpl$', template):
+ if os.path.splitext(template)[1] == '.ewd' or re.match(r".*\.ewd.tmpl$", template):
# get ewd template
try:
ewd_dic = xmltodict.parse(open(template,'rb'), dict_constructor=dict)
@@ -518,9 +518,8 @@
def _parse_subprocess_output(self, output):
num_errors = 0
lines = output.split("\n")
- error_re = '\s*Total number of errors:\s*(\d+)\s*'
for line in lines:
- m = re.match(error_re, line)
+ m = re.match(r"\s*Total number of errors:\s*(\d+)\s*", line)
if m is not None:
num_errors = m.group(1)
return int(num_errors)
--- a/project_generator/tools/uvision.py
+++ b/project_generator/tools/uvision.py
@@ -403,7 +403,7 @@
for template in expanded_dic['template']:
template = join(getcwd(), template)
if os.path.splitext(template)[1] == '.uvproj' or os.path.splitext(template)[1] == '.uvprojx' or \
- re.match('.*\.uvproj.tmpl$', template) or re.match('.*\.uvprojx.tmpl$', template):
+ re.match(r".*\.uvproj.tmpl$", template) or re.match(r".*\.uvprojx.tmpl$", template):
try:
uvproj_dic = xmltodict.parse(open(template, encoding="utf8").read())
except IOError:
@@ -417,7 +417,7 @@
for template in self.env_settings.templates['uvision']:
template = join(getcwd(), template)
if os.path.splitext(template)[1] == '.uvproj' or os.path.splitext(template)[1] == '.uvprojx' or \
- re.match('.*\.uvproj.tmpl$', template) or re.match('.*\.uvprojx.tmpl$', template):
+ re.match(r".*\.uvproj.tmpl$", template) or re.match(r".*\.uvprojx.tmpl$", template):
try:
uvproj_dic = xmltodict.parse(open(template, encoding="utf8").read())
except IOError:
|