Created
November 30, 2021 15:10
-
-
Save mikahanninen/8074061883388787654970587d594678 to your computer and use it in GitHub Desktop.
libspeccing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def modify_libspec_files(): | |
files = list_all_libspec_files() | |
pattern = r"source=\"([^\"]+)" | |
sub_pattern = rf'source=".\{os.path.sep}\g<1>' | |
for f in files: | |
outfilename = f"{f}.modified" | |
with open(f) as file_in: | |
file_content = file_in.read() | |
with open(outfilename, "w") as file_out: | |
new_content = re.sub( | |
pattern, sub_pattern, file_content, 0, re.MULTILINE | |
) | |
file_out.write(new_content) | |
Path(f).unlink() | |
Path(outfilename).rename(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment