From 73462e4b83f36bc3b74f66820090d458569dfcd4 Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Sun, 13 Oct 2024 19:25:56 +0100 Subject: [PATCH] feature: create output dir script --- src/app.py | 7 +++---- src/constants.py | 2 +- src/copy_zettels.py | 11 ----------- src/lib/create_source_dir.py | 21 +++++++++++++++++++++ 4 files changed, 25 insertions(+), 16 deletions(-) delete mode 100644 src/copy_zettels.py create mode 100644 src/lib/create_source_dir.py diff --git a/src/app.py b/src/app.py index 6005117..eb0619e 100644 --- a/src/app.py +++ b/src/app.py @@ -1,12 +1,11 @@ from constants import SOURCE from constants import TARGET -from copy_zettels import copy_zettels +from lib.create_source_dir import create_source_dir def main(): - print("this is the app") - print(SOURCE) - copy_zettels() + output_dir = create_source_dir() + print(output_dir) if __name__ == "__main__": diff --git a/src/constants.py b/src/constants.py index 5fcbf40..42ca259 100644 --- a/src/constants.py +++ b/src/constants.py @@ -1,2 +1,2 @@ SOURCE = "/home/thomas/repos/eolas" -TARGET = "/home/thomas/repos/output" +TARGET = "/home/thomas/Desktop/output" diff --git a/src/copy_zettels.py b/src/copy_zettels.py deleted file mode 100644 index 837fb5e..0000000 --- a/src/copy_zettels.py +++ /dev/null @@ -1,11 +0,0 @@ -import os -import shutil -from constants import SOURCE, TARGET -from pathlib import Path - - -def copy_zettels(): - if os.path.isdir(TARGET): - shutil.rmtree(TARGET) - - # p.mkdir() diff --git a/src/lib/create_source_dir.py b/src/lib/create_source_dir.py new file mode 100644 index 0000000..4b51a01 --- /dev/null +++ b/src/lib/create_source_dir.py @@ -0,0 +1,21 @@ +import os +import shutil +import uuid +from termcolor import colored +from constants import SOURCE, TARGET +from pathlib import Path + + +def create_source_dir(): + unique_dir_name = uuid.uuid4() + if os.path.isdir(TARGET): + shutil.rmtree(TARGET) + + # Create route directory and /static directory + os.makedirs(f"{TARGET}/{str(unique_dir_name)}/static") + print( + colored( + f"Created new Neuron output directory: {SOURCE}/{unique_dir_name}", "green" + ) + ) + return unique_dir_name