File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#!/usr/bin/python
22
33import 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
810with open (filepath , 'r' ) as f :
911 lines = f .readlines ()
1012
1113with 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 ))
You can’t perform that action at this time.
0 commit comments