From 7da02b8777578beef0967c29577a2e90446e1417 Mon Sep 17 00:00:00 2001 From: jwansek Date: Fri, 8 Mar 2024 15:34:34 +0000 Subject: Added the scripts --- .gitignore | 2 ++ linebreakadder/Makefile | 7 +++++++ linebreakadder/linebreakadder.py | 27 +++++++++++++++++++++++++++ linebreakremover/Makefile | 7 +++++++ linebreakremover/linebreakremover.py | 17 +++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 linebreakadder/Makefile create mode 100644 linebreakadder/linebreakadder.py create mode 100644 linebreakremover/Makefile create mode 100644 linebreakremover/linebreakremover.py diff --git a/.gitignore b/.gitignore index 68bc17f..5cfbf17 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*.rot + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/linebreakadder/Makefile b/linebreakadder/Makefile new file mode 100644 index 0000000..f040b73 --- /dev/null +++ b/linebreakadder/Makefile @@ -0,0 +1,7 @@ +make: + pyinstaller linebreakadder.py --onefile + +clean: + rm -r build/ + rm -r dist/ + rm linebreakremover.spec \ No newline at end of file diff --git a/linebreakadder/linebreakadder.py b/linebreakadder/linebreakadder.py new file mode 100644 index 0000000..8b33c5d --- /dev/null +++ b/linebreakadder/linebreakadder.py @@ -0,0 +1,27 @@ +import sys +import re + +try: + input_path = sys.argv[1] + output_path = sys.argv[2] +except IndexError: + print("You need to specify the path to the .rot file as the first parameter and the output file path as the second parameter e.g. python linebreakadder.exe Rotation.rot output.rot") + exit(-1) + +with open(input_path, "r") as f: + input_ = f.read() + +lines = re.sub(r"\n{2,}", "\n", input_) + +thelastnumber = None +output = "" +for i, line in enumerate(lines.split("\n"), 0): + if line.split(" ")[0] != thelastnumber and output != "": + output += "\n" + + output += line + "\n" + + thelastnumber = line.split(" ")[0] + +with open(output_path, "w") as fo: + fo.write(output[:-2]) \ No newline at end of file diff --git a/linebreakremover/Makefile b/linebreakremover/Makefile new file mode 100644 index 0000000..2d5e244 --- /dev/null +++ b/linebreakremover/Makefile @@ -0,0 +1,7 @@ +make: + pyinstaller linebreakremover.py --onefile + +clean: + rm -r build/ + rm -r dist/ + rm linebreakremover.spec \ No newline at end of file diff --git a/linebreakremover/linebreakremover.py b/linebreakremover/linebreakremover.py new file mode 100644 index 0000000..051aac3 --- /dev/null +++ b/linebreakremover/linebreakremover.py @@ -0,0 +1,17 @@ +import sys +import re + +try: + input_path = sys.argv[1] + output_path = sys.argv[2] +except IndexError: + print("You need to specify the path to the .rot file as the first parameter and the output file path as the second parameter e.g. python linebreaker.py Rotation.rot output.rot") + exit(-1) + +with open(input_path, "r") as f: + input_ = f.read() + +output = re.sub(r"\n{2,}", "\n", input_) + +with open(output_path, "w") as f: + f.write(output) -- cgit v1.2.3