Skip to content

Commit 8ec8299

Browse files
authored
Update PrintHierarchy.py
1 parent 4d19dc5 commit 8ec8299

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

PrintHierarchy.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
## Copyright (c) Jonathan Serrano, 2023
77
## ---------------------------
88

9+
#!/usr/local/bin python3
10+
## ---------------------------
11+
## Script name: PrintHierarchy.py
12+
## Purpose: Input file paths and print out file heirarchy tree
13+
## Author: Jonathan Serrano
14+
## Copyright (c) Jonathan Serrano, 2023
15+
## ---------------------------
16+
917
import sys
1018
import os
1119

@@ -43,17 +51,8 @@ def main(input_paths):
4351
print(f"Tree output saved to: {output_file_path}")
4452

4553
def test():
46-
home_dir = os.path.expanduser("~")
47-
home_tree = {"~": {}}
48-
for root, dirs, files in os.walk(home_dir):
49-
curr_dir = root.replace(home_dir, "~")
50-
parent_dir = os.path.dirname(curr_dir)
51-
add_to_tree(home_tree.setdefault(parent_dir, {}), [os.path.basename(curr_dir)])
52-
for file in files:
53-
add_to_tree(home_tree.setdefault(curr_dir, {}), [file])
54-
55-
print("Home Folder Hierarchy:")
56-
print_tree(home_tree)
54+
input_paths = ["dir1/dir2/file1.txt", "dir1/dir3/file2.txt", "dir4/file3.txt"]
55+
main(input_paths)
5756

5857
if __name__ == "__main__":
5958
input_paths = sys.argv[1:]

0 commit comments

Comments
 (0)