Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use raw strings in re.match #510

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions project_generator/tools/coide.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _export_single_project(self):
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:
Expand All @@ -161,7 +161,7 @@ def _export_single_project(self):
# 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:
Expand Down
11 changes: 5 additions & 6 deletions project_generator/tools/iar.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,14 @@ def _export_single_project(self):
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
Expand All @@ -399,14 +399,14 @@ def _export_single_project(self):
# 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)
Expand Down Expand Up @@ -518,9 +518,8 @@ def _generate_eww_file(self):
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)
Expand Down
4 changes: 2 additions & 2 deletions project_generator/tools/uvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def _export_single_project(self, tool_name):
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:
Expand All @@ -417,7 +417,7 @@ def _export_single_project(self, tool_name):
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:
Expand Down
Loading