Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding txt files to the leaf nodes #2

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions mdharvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand All @@ -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')

Expand Down
1 change: 1 addition & 0 deletions test_dir1/2023/01/01/2023-01-01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File created at: test_dir1/2023/01/01
1 change: 1 addition & 0 deletions test_dir1/2023/01/02/2023-01-02.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File created at: test_dir1/2023/01/02
1 change: 1 addition & 0 deletions test_dir1/2023/01/03/2023-01-03.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File created at: test_dir1/2023/01/03
1 change: 1 addition & 0 deletions test_dir1/2023/01/04/2023-01-04.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File created at: test_dir1/2023/01/04
1 change: 1 addition & 0 deletions test_dir1/2023/01/05/2023-01-05.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File created at: test_dir1/2023/01/05
1 change: 1 addition & 0 deletions test_dir3/2022/01/01/2022-01-01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File created at: test_dir3/2022/01/01
1 change: 1 addition & 0 deletions test_dir3/2022/01/02/2022-01-02.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File created at: test_dir3/2022/01/02
1 change: 1 addition & 0 deletions test_dir3/2022/01/03/2022-01-03.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File created at: test_dir3/2022/01/03
1 change: 1 addition & 0 deletions test_dir3/2022/01/04/2022-01-04.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File created at: test_dir3/2022/01/04
1 change: 1 addition & 0 deletions test_dir3/2022/01/05/2022-01-05.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File created at: test_dir3/2022/01/05
1 change: 1 addition & 0 deletions test_dir4/2022/01/01/2022-01-01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File created at: test_dir4/2022/01/01
Loading