Created
June 3, 2018 04:42
-
-
Save nyanpasu64/ed0a7d832209d17e48adc5cccc2dedcb to your computer and use it in GitHub Desktop.
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 re | |
| import sys | |
| def exitPrompt(string="Press enter to exit. . ."): | |
| input(string) | |
| exit() | |
| def error(string, quit=True): | |
| if (quit): exitPrompt("Error: %s" % string) | |
| else: print(string) | |
| def main(): | |
| if (len(sys.argv) > 1): | |
| if (len(sys.argv) > 2): | |
| error("Too many arguments.") | |
| filename = sys.argv[1] | |
| else: | |
| filename = str(input("Enter filename: ")) | |
| file = open(filename, 'r') | |
| lines = file.readlines() | |
| file.close() | |
| file = open(filename, 'w') | |
| for line in lines: | |
| line = re.sub(r"(?<=\^)[a-g][\+\-]?", '', line, flags=re.IGNORECASE) | |
| file.write(line) | |
| file.close() | |
| print("Done.") | |
| exitPrompt() | |
| if (__name__ == "__main__"): | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment