replace semicolons with greek questionmarks

This commit is contained in:
Christoph J. Scherr 2024-03-06 13:51:02 +01:00
parent 95866bca81
commit 564b0cd011
Signed by: cscherrNT
GPG Key ID: 8E2B45BC51A27EA7
1 changed files with 34 additions and 0 deletions

34
src/greek_to_me.py Normal file
View File

@ -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()