Skip to content

Commit

Permalink
infra/generate_skels: Fix regex warnings
Browse files Browse the repository at this point in the history
Prefix regex strings with 'r' to avoid syntax warnings for unescaped
character.

GitHub-Fixes: #107

Signed-off-by: Alex Apostolescu <[email protected]>
  • Loading branch information
Alex-deVis committed Oct 21, 2024
1 parent 329dfab commit c9d0ca0
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 196 deletions.
37 changes: 20 additions & 17 deletions chapters/data/process-memory/drills/tasks/copy/generate_skels.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,37 +93,40 @@ def main():
args = parser.parse_args()

for root, dirs, files in os.walk(args.input):
new_root = os.path.join(args.output, root.replace(args.input, "").lstrip("/"))
new_root = os.path.join(args.output, os.path.relpath(root, args.input))
for d in dirs:
os.makedirs(os.path.join(new_root, d), exist_ok=True)

for src in files:
if (
re.match("Makefile.*$", src)
or re.match(".*\.sh$", src)
or re.match(".*\.[sS]$", src)
or re.match(r".*\.sh$", src)
or re.match(r".*\.[sS]$", src)
):
pattern = "(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*#\s*REPLACE)( [0-9]*)"
remove = "(^\s*#\s*REMOVE)( [0-9]*)"
pattern = r"(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*#\s*REPLACE)( [0-9]*)"
remove = r"(^\s*#\s*REMOVE)( [0-9]*)"
replace_pairs = [("# ", "")]
end_string = None
elif re.match(".*\.asm$", src):
pattern = "(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*;\s*REPLACE)( [0-9]*)"
remove = "(^\s*;\s*REMOVE)( [0-9]*)"
elif re.match(r".*\.asm$", src):
pattern = r"(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*;\s*REPLACE)( [0-9]*)"
remove = r"(^\s*;\s*REMOVE)( [0-9]*)"
replace_pairs = [("; ", "")]
end_string = None
elif (
re.match(".*\.[chd]$", src)
or re.match(".*\.cpp$", src)
or re.match(".*\.hpp$", src)
re.match(r".*\.[ch]$", src)
or re.match(r".*\.cpp$", src)
or re.match(r".*\.hpp$", src)
):
pattern = "(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = "(.*/\*\s*REPLACE)( [0-9]*)"
remove = "(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [("/\* ", ""), (" \*/", "")]
pattern = r"(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*/\*\s*REPLACE)( [0-9]*)"
remove = r"(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [(r"/\* ", ""), (r" \*/", "")]
end_string = "*/"
elif re.match(r".*\.d$", src):
pattern = r"(.*//\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*//\s*REPLACE)( [0-9]*)"
else:
continue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,40 +93,40 @@ def main():
args = parser.parse_args()

for root, dirs, files in os.walk(args.input):
new_root = os.path.join(args.output, root.replace(args.input, ""))
new_root = os.path.join(args.output, os.path.relpath(root, args.input))
for d in dirs:
os.makedirs(os.path.join(new_root, d), exist_ok=True)

for src in files:
if (
re.match("Makefile.*$", src)
or re.match(".*\.sh$", src)
or re.match(".*\.[sS]$", src)
or re.match(r".*\.sh$", src)
or re.match(r".*\.[sS]$", src)
):
pattern = "(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*#\s*REPLACE)( [0-9]*)"
remove = "(^\s*#\s*REMOVE)( [0-9]*)"
pattern = r"(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*#\s*REPLACE)( [0-9]*)"
remove = r"(^\s*#\s*REMOVE)( [0-9]*)"
replace_pairs = [("# ", "")]
end_string = None
elif re.match(".*\.asm$", src):
pattern = "(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*;\s*REPLACE)( [0-9]*)"
remove = "(^\s*;\s*REMOVE)( [0-9]*)"
elif re.match(r".*\.asm$", src):
pattern = r"(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*;\s*REPLACE)( [0-9]*)"
remove = r"(^\s*;\s*REMOVE)( [0-9]*)"
replace_pairs = [("; ", "")]
end_string = None
elif (
re.match(".*\.[ch]$", src)
or re.match(".*\.cpp$", src)
or re.match(".*\.hpp$", src)
re.match(r".*\.[ch]$", src)
or re.match(r".*\.cpp$", src)
or re.match(r".*\.hpp$", src)
):
pattern = "(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = "(.*/\*\s*REPLACE)( [0-9]*)"
remove = "(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [("/\* ", ""), (" \*/", "")]
pattern = r"(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*/\*\s*REPLACE)( [0-9]*)"
remove = r"(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [(r"/\* ", ""), (r" \*/", "")]
end_string = "*/"
elif re.match(".*\.d$", src):
pattern = "(.*//\s*TODO)([ 0-9]*)(:.*)"
replace = "(.*//\s*REPLACE)( [0-9]*)"
elif re.match(r".*\.d$", src):
pattern = r"(.*//\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*//\s*REPLACE)( [0-9]*)"
else:
continue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,37 +93,40 @@ def main():
args = parser.parse_args()

for root, dirs, files in os.walk(args.input):
new_root = os.path.join(args.output, root.replace(args.input, ""))
new_root = os.path.join(args.output, os.path.relpath(root, args.input))
for d in dirs:
os.makedirs(os.path.join(new_root, d), exist_ok=True)

for src in files:
if (
re.match("Makefile.*$", src)
or re.match(".*\.sh$", src)
or re.match(".*\.[sS]$", src)
or re.match(r".*\.sh$", src)
or re.match(r".*\.[sS]$", src)
):
pattern = "(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*#\s*REPLACE)( [0-9]*)"
remove = "(^\s*#\s*REMOVE)( [0-9]*)"
pattern = r"(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*#\s*REPLACE)( [0-9]*)"
remove = r"(^\s*#\s*REMOVE)( [0-9]*)"
replace_pairs = [("# ", "")]
end_string = None
elif re.match(".*\.asm$", src):
pattern = "(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*;\s*REPLACE)( [0-9]*)"
remove = "(^\s*;\s*REMOVE)( [0-9]*)"
elif re.match(r".*\.asm$", src):
pattern = r"(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*;\s*REPLACE)( [0-9]*)"
remove = r"(^\s*;\s*REMOVE)( [0-9]*)"
replace_pairs = [("; ", "")]
end_string = None
elif (
re.match(".*\.[chd]$", src)
or re.match(".*\.cpp$", src)
or re.match(".*\.hpp$", src)
re.match(r".*\.[ch]$", src)
or re.match(r".*\.cpp$", src)
or re.match(r".*\.hpp$", src)
):
pattern = "(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = "(.*/\*\s*REPLACE)( [0-9]*)"
remove = "(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [("/\* ", ""), (" \*/", "")]
pattern = r"(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*/\*\s*REPLACE)( [0-9]*)"
remove = r"(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [(r"/\* ", ""), (r" \*/", "")]
end_string = "*/"
elif re.match(r".*\.d$", src):
pattern = r"(.*//\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*//\s*REPLACE)( [0-9]*)"
else:
continue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,40 +93,40 @@ def main():
args = parser.parse_args()

for root, dirs, files in os.walk(args.input):
new_root = os.path.join(args.output, root.replace(args.input, ""))
new_root = os.path.join(args.output, os.path.relpath(root, args.input))
for d in dirs:
os.makedirs(os.path.join(new_root, d), exist_ok=True)

for src in files:
if (
re.match("Makefile.*$", src)
or re.match(".*\.sh$", src)
or re.match(".*\.[sS]$", src)
or re.match(r".*\.sh$", src)
or re.match(r".*\.[sS]$", src)
):
pattern = "(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*#\s*REPLACE)( [0-9]*)"
remove = "(^\s*#\s*REMOVE)( [0-9]*)"
pattern = r"(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*#\s*REPLACE)( [0-9]*)"
remove = r"(^\s*#\s*REMOVE)( [0-9]*)"
replace_pairs = [("# ", "")]
end_string = None
elif re.match(".*\.asm$", src):
pattern = "(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*;\s*REPLACE)( [0-9]*)"
remove = "(^\s*;\s*REMOVE)( [0-9]*)"
elif re.match(r".*\.asm$", src):
pattern = r"(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*;\s*REPLACE)( [0-9]*)"
remove = r"(^\s*;\s*REMOVE)( [0-9]*)"
replace_pairs = [("; ", "")]
end_string = None
elif (
re.match(".*\.[ch]$", src)
or re.match(".*\.cpp$", src)
or re.match(".*\.hpp$", src)
re.match(r".*\.[ch]$", src)
or re.match(r".*\.cpp$", src)
or re.match(r".*\.hpp$", src)
):
pattern = "(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = "(.*/\*\s*REPLACE)( [0-9]*)"
remove = "(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [("/\* ", ""), (" \*/", "")]
pattern = r"(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*/\*\s*REPLACE)( [0-9]*)"
remove = r"(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [(r"/\* ", ""), (r" \*/", "")]
end_string = "*/"
elif re.match(".*\.d$", src):
pattern = "(.*//\s*TODO)([ 0-9]*)(:.*)"
replace = "(.*//\s*REPLACE)( [0-9]*)"
elif re.match(r".*\.d$", src):
pattern = r"(.*//\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*//\s*REPLACE)( [0-9]*)"
else:
continue

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python3 -u
# SPDX-License-Identifier: BSD-3-Clause

import sys
import argparse
Expand Down Expand Up @@ -92,40 +93,40 @@ def main():
args = parser.parse_args()

for root, dirs, files in os.walk(args.input):
new_root = os.path.join(args.output, root.replace(args.input, ""))
new_root = os.path.join(args.output, os.path.relpath(root, args.input))
for d in dirs:
os.makedirs(os.path.join(new_root, d), exist_ok=True)

for src in files:
if (
re.match("Makefile.*$", src)
or re.match(".*\.sh$", src)
or re.match(".*\.[sS]$", src)
or re.match(r".*\.sh$", src)
or re.match(r".*\.[sS]$", src)
):
pattern = "(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*#\s*REPLACE)( [0-9]*)"
remove = "(^\s*#\s*REMOVE)( [0-9]*)"
pattern = r"(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*#\s*REPLACE)( [0-9]*)"
remove = r"(^\s*#\s*REMOVE)( [0-9]*)"
replace_pairs = [("# ", "")]
end_string = None
elif re.match(".*\.asm$", src):
pattern = "(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*;\s*REPLACE)( [0-9]*)"
remove = "(^\s*;\s*REMOVE)( [0-9]*)"
elif re.match(r".*\.asm$", src):
pattern = r"(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*;\s*REPLACE)( [0-9]*)"
remove = r"(^\s*;\s*REMOVE)( [0-9]*)"
replace_pairs = [("; ", "")]
end_string = None
elif (
re.match(".*\.[ch]$", src)
or re.match(".*\.cpp$", src)
or re.match(".*\.hpp$", src)
re.match(r".*\.[ch]$", src)
or re.match(r".*\.cpp$", src)
or re.match(r".*\.hpp$", src)
):
pattern = "(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = "(.*/\*\s*REPLACE)( [0-9]*)"
remove = "(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [("/\* ", ""), (" \*/", "")]
pattern = r"(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*/\*\s*REPLACE)( [0-9]*)"
remove = r"(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [(r"/\* ", ""), (r" \*/", "")]
end_string = "*/"
elif re.match(".*\.d$", src):
pattern = "(.*//\s*TODO)([ 0-9]*)(:.*)"
replace = "(.*//\s*REPLACE)( [0-9]*)"
elif re.match(r".*\.d$", src):
pattern = r"(.*//\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*//\s*REPLACE)( [0-9]*)"
else:
continue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,42 +93,40 @@ def main():
args = parser.parse_args()

for root, dirs, files in os.walk(args.input):
new_root = os.path.join(args.output, root.replace(args.input, ""))
new_root = os.path.join(args.output, os.path.relpath(root, args.input))
for d in dirs:
os.makedirs(os.path.join(new_root, d), exist_ok=True)

for src in files:
if (
re.match("Makefile.*$", src)
or re.match(".*\.sh$", src)
or re.match(".*\.[sS]$", src)
or re.match(".*\.py$", src)
or re.match(r".*\.sh$", src)
or re.match(r".*\.[sS]$", src)
):
pattern = "(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*#\s*REPLACE)( [0-9]*)"
remove = "(^\s*#\s*REMOVE)( [0-9]*)"
pattern = r"(^\s*#\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*#\s*REPLACE)( [0-9]*)"
remove = r"(^\s*#\s*REMOVE)( [0-9]*)"
replace_pairs = [("# ", "")]
end_string = None
elif re.match(".*\.asm$", src):
pattern = "(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = "(^\s*;\s*REPLACE)( [0-9]*)"
remove = "(^\s*;\s*REMOVE)( [0-9]*)"
elif re.match(r".*\.asm$", src):
pattern = r"(^\s*;\s*TODO)( [0-9]*)(:.*)"
replace = r"(^\s*;\s*REPLACE)( [0-9]*)"
remove = r"(^\s*;\s*REMOVE)( [0-9]*)"
replace_pairs = [("; ", "")]
end_string = None
elif (
re.match(".*\.[ch]$", src)
or re.match(".*\.cpp$", src)
or re.match(".*\.hpp$", src)
or re.match(".*\.go$", src)
re.match(r".*\.[ch]$", src)
or re.match(r".*\.cpp$", src)
or re.match(r".*\.hpp$", src)
):
pattern = "(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = "(.*/\*\s*REPLACE)( [0-9]*)"
remove = "(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [("/\* ", ""), (" \*/", "")]
pattern = r"(.*/\*\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*/\*\s*REPLACE)( [0-9]*)"
remove = r"(.*/\*\s*REMOVE)( [0-9]*)"
replace_pairs = [(r"/\* ", ""), (r" \*/", "")]
end_string = "*/"
elif re.match(".*\.d$", src):
pattern = "(.*//\s*TODO)([ 0-9]*)(:.*)"
replace = "(.*//\s*REPLACE)( [0-9]*)"
elif re.match(r".*\.d$", src):
pattern = r"(.*//\s*TODO)([ 0-9]*)(:.*)"
replace = r"(.*//\s*REPLACE)( [0-9]*)"
else:
continue

Expand Down
Loading

0 comments on commit c9d0ca0

Please sign in to comment.