Skip to content

Commit

Permalink
Merge pull request #2 from FNNDSC/mhu/file-in-leaf
Browse files Browse the repository at this point in the history
adding txt files to the leaf nodes
  • Loading branch information
matthewhu8 authored Aug 9, 2024
2 parents c6978db + 8f57016 commit 544fe25
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 5 deletions.
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

0 comments on commit 544fe25

Please sign in to comment.