Skip to content

Instantly share code, notes, and snippets.

@mikahanninen
Created November 30, 2021 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikahanninen/8074061883388787654970587d594678 to your computer and use it in GitHub Desktop.
Save mikahanninen/8074061883388787654970587d594678 to your computer and use it in GitHub Desktop.
libspeccing
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