Skip to content

Commit f39dfde

Browse files
committed
Update remove_teensyloader.py
The build hook pattern changed with Teensyduino 1.55, which breaks the CI.
1 parent b24a46c commit f39dfde

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
#!/usr/bin/python
22

33
import sys
4+
import re
45

5-
filepath = sys.argv[1]
6-
lines = []
6+
filepath = sys.argv[1] # path of the file to parse
7+
lines = [] # list of lines from the file
8+
removed = False # flag for if the line was removed from the file
79

810
with open(filepath, 'r') as f:
911
lines = f.readlines()
1012

1113
with open(filepath, 'w') as f:
14+
# matching "postbuild" hooks of any number which call the "teensy_post_compile" application
15+
pattern = re.compile("recipe\.hooks\.postbuild\.[0-9]\.pattern=\"{compiler\.path}teensy_post_compile\"")
1216
for line in lines:
13-
if not line.startswith("recipe.hooks.postbuild.3.pattern=\"{compiler.path}teensy_post_compile\""): # remove post-compile trigger
17+
if not pattern.match(line):
1418
f.write(line)
1519
else:
1620
print("Removing line '{}'".format(line.strip('\n')))
21+
removed = True
22+
23+
if not removed:
24+
raise RuntimeError("Did not find a matching line to remove in \"{}\"".format(filepath))

0 commit comments

Comments
 (0)