From 564b0cd01177b7d8f6bbe1679c1890cd92678805 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Wed, 6 Mar 2024 13:51:02 +0100 Subject: [PATCH] replace semicolons with greek questionmarks --- src/greek_to_me.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/greek_to_me.py diff --git a/src/greek_to_me.py b/src/greek_to_me.py new file mode 100644 index 0000000..8439af3 --- /dev/null +++ b/src/greek_to_me.py @@ -0,0 +1,34 @@ +import os +import sys + +def greek(path: str): + """replace all semicolons in the given file with Greek question marks""" + contents: str = "" + with open(path, "r") as file: + contents = file.read() + contents = contents.replace(";", "\u037e") + with open(path, "w") as file: + file.write(contents) + file.flush() + +def main(): + """ + Turn all semicolons ';' of the target files into Greek question marks 'Íž'. + + For compilers and interpreters, this is a completely different character, + but to humans, it looks the same. The Rust compiler is smart enough to warn + us that it only looks like a semicolon. Use more Rust. + """ + if sys.argv.__len__() < 2: + print("provide filepaths as arguments") + + paths: list[str] = [] + for index, arg in enumerate(sys.argv): + if os.path.exists(arg) and os.path.isfile(arg) and index > 0: + paths.append(arg) + + for path in paths: + greek(path) + +if __name__ == "__main__": + main()