From 8f570167368be2e87ff183273a4d3f256475c4be Mon Sep 17 00:00:00 2001 From: matthewhu8 Date: Fri, 9 Aug 2024 13:57:08 -0400 Subject: [PATCH] adding txt files to the leaf nodes --- mdharvester.py | 14 +++++++++----- test_dir1/2023/01/01/2023-01-01.txt | 1 + test_dir1/2023/01/02/2023-01-02.txt | 1 + test_dir1/2023/01/03/2023-01-03.txt | 1 + test_dir1/2023/01/04/2023-01-04.txt | 1 + test_dir1/2023/01/05/2023-01-05.txt | 1 + test_dir3/2022/01/01/2022-01-01.txt | 1 + test_dir3/2022/01/02/2022-01-02.txt | 1 + test_dir3/2022/01/03/2022-01-03.txt | 1 + test_dir3/2022/01/04/2022-01-04.txt | 1 + test_dir3/2022/01/05/2022-01-05.txt | 1 + test_dir4/2022/01/01/2022-01-01.txt | 1 + 12 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 test_dir1/2023/01/01/2023-01-01.txt create mode 100644 test_dir1/2023/01/02/2023-01-02.txt create mode 100644 test_dir1/2023/01/03/2023-01-03.txt create mode 100644 test_dir1/2023/01/04/2023-01-04.txt create mode 100644 test_dir1/2023/01/05/2023-01-05.txt create mode 100644 test_dir3/2022/01/01/2022-01-01.txt create mode 100644 test_dir3/2022/01/02/2022-01-02.txt create mode 100644 test_dir3/2022/01/03/2022-01-03.txt create mode 100644 test_dir3/2022/01/04/2022-01-04.txt create mode 100644 test_dir3/2022/01/05/2022-01-05.txt create mode 100644 test_dir4/2022/01/01/2022-01-01.txt diff --git a/mdharvester.py b/mdharvester.py index 82485a6..9293552 100644 --- a/mdharvester.py +++ b/mdharvester.py @@ -60,6 +60,7 @@ def main(options: Namespace, inputdir: Path, outputdir: Path): print(DISPLAY_TITLE) test_dateTreeBuild() + def dateTreeBuild(start_date, end_date, outputdir): #Create Datetime objects @@ -87,9 +88,14 @@ def dateTreeBuild(start_date, end_date, outputdir): directory_path = os.path.join(str(outputdir), year, month, day) print(f"Making path: {directory_path}") - os.makedirs(directory_path, exist_ok = True) - - current_date += timedelta(days = 1) + os.makedirs(directory_path, exist_ok=True) + + file_name = f"{year}-{month}-{day}.txt" + file_path = os.path.join(directory_path, file_name) + with open(file_path, 'w') as file: + file.write(f"File created at: {directory_path}\n") + + current_date += timedelta(days=1) def test_dateTreeBuild(): print("Test1: Valid Date Range") @@ -104,8 +110,6 @@ def test_dateTreeBuild(): except SystemExit as e: print("Caught an expected SystemExit due to invalid date format") - - print("\nTest 4: Same Start and End Date") dateTreeBuild('20220101', '20220101', 'test_dir4') diff --git a/test_dir1/2023/01/01/2023-01-01.txt b/test_dir1/2023/01/01/2023-01-01.txt new file mode 100644 index 0000000..af9f55c --- /dev/null +++ b/test_dir1/2023/01/01/2023-01-01.txt @@ -0,0 +1 @@ +File created at: test_dir1/2023/01/01 diff --git a/test_dir1/2023/01/02/2023-01-02.txt b/test_dir1/2023/01/02/2023-01-02.txt new file mode 100644 index 0000000..b55c063 --- /dev/null +++ b/test_dir1/2023/01/02/2023-01-02.txt @@ -0,0 +1 @@ +File created at: test_dir1/2023/01/02 diff --git a/test_dir1/2023/01/03/2023-01-03.txt b/test_dir1/2023/01/03/2023-01-03.txt new file mode 100644 index 0000000..8835958 --- /dev/null +++ b/test_dir1/2023/01/03/2023-01-03.txt @@ -0,0 +1 @@ +File created at: test_dir1/2023/01/03 diff --git a/test_dir1/2023/01/04/2023-01-04.txt b/test_dir1/2023/01/04/2023-01-04.txt new file mode 100644 index 0000000..42f7e45 --- /dev/null +++ b/test_dir1/2023/01/04/2023-01-04.txt @@ -0,0 +1 @@ +File created at: test_dir1/2023/01/04 diff --git a/test_dir1/2023/01/05/2023-01-05.txt b/test_dir1/2023/01/05/2023-01-05.txt new file mode 100644 index 0000000..50c639b --- /dev/null +++ b/test_dir1/2023/01/05/2023-01-05.txt @@ -0,0 +1 @@ +File created at: test_dir1/2023/01/05 diff --git a/test_dir3/2022/01/01/2022-01-01.txt b/test_dir3/2022/01/01/2022-01-01.txt new file mode 100644 index 0000000..cf8798c --- /dev/null +++ b/test_dir3/2022/01/01/2022-01-01.txt @@ -0,0 +1 @@ +File created at: test_dir3/2022/01/01 diff --git a/test_dir3/2022/01/02/2022-01-02.txt b/test_dir3/2022/01/02/2022-01-02.txt new file mode 100644 index 0000000..d56d2af --- /dev/null +++ b/test_dir3/2022/01/02/2022-01-02.txt @@ -0,0 +1 @@ +File created at: test_dir3/2022/01/02 diff --git a/test_dir3/2022/01/03/2022-01-03.txt b/test_dir3/2022/01/03/2022-01-03.txt new file mode 100644 index 0000000..f21ddfe --- /dev/null +++ b/test_dir3/2022/01/03/2022-01-03.txt @@ -0,0 +1 @@ +File created at: test_dir3/2022/01/03 diff --git a/test_dir3/2022/01/04/2022-01-04.txt b/test_dir3/2022/01/04/2022-01-04.txt new file mode 100644 index 0000000..1221a8f --- /dev/null +++ b/test_dir3/2022/01/04/2022-01-04.txt @@ -0,0 +1 @@ +File created at: test_dir3/2022/01/04 diff --git a/test_dir3/2022/01/05/2022-01-05.txt b/test_dir3/2022/01/05/2022-01-05.txt new file mode 100644 index 0000000..8b137b0 --- /dev/null +++ b/test_dir3/2022/01/05/2022-01-05.txt @@ -0,0 +1 @@ +File created at: test_dir3/2022/01/05 diff --git a/test_dir4/2022/01/01/2022-01-01.txt b/test_dir4/2022/01/01/2022-01-01.txt new file mode 100644 index 0000000..1166da4 --- /dev/null +++ b/test_dir4/2022/01/01/2022-01-01.txt @@ -0,0 +1 @@ +File created at: test_dir4/2022/01/01