Last active
May 18, 2019 10:08
-
-
Save plammens/dcd6d4b4a8c3a0f0d49318dead520fbe to your computer and use it in GitHub Desktop.
Quick throwaway script for temporarily fixing https://github.com/pngwriter/pngwriter/issues/136
This file contains hidden or 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
import glob | |
import re | |
pattern = re.compile(r"-D(?= *-D)") | |
for filename in glob.glob("CMakeFiles/*.dir/flags.make"): | |
print("Inspecting '{}'. ".format(filename), end='') | |
with open(filename, 'r') as file: | |
lines = file.readlines() | |
assert "CXX_DEFINES" in lines[6] | |
found_problems: bool = bool(re.search(pattern, lines[6])) | |
if found_problems: | |
print("Editing... ", end='') | |
lines[6] = re.sub(r"-D(?= *-D)", "", lines[6]) | |
with open(filename, 'w') as file: | |
file.writelines(lines) | |
print("Done.") | |
else: | |
print("No problems found. ", end='') | |
print("\nAll done. Try `make install` again.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment