-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_backend_directory_structure.py
49 lines (41 loc) · 1.69 KB
/
c_backend_directory_structure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import json
import os
from datetime import datetime
def analyze_backend_directory(backend_path, output_path):
"""
Creates a JSON file representing the directory structure of the backend,
excluding the Original folder.
"""
directory_structure = {
"project_name": "Backend Structure",
"analysis_date": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"version": 1,
"directories": {}
}
# Walk through the directory
for root, dirs, files in os.walk(backend_path):
# Skip the Original folder and its contents
if "Original" in root:
continue
# Get relative path from backend directory
rel_path = os.path.relpath(root, backend_path)
if rel_path == ".":
continue
# Add directory to structure
directory_structure["directories"][rel_path] = {
"files": [os.path.join(rel_path, f) for f in files],
"import_count": len(files) # Simple count of files as import count
}
# Write the output JSON file
with open(output_path, 'w') as f:
json.dump(directory_structure, f, indent=2)
def main():
backend_path = r"C:\Users\md8w7\OneDrive University of Missouri\Desktop\ImportantFiles\Milestone4\backend"
output_path = r"C:\Users\md8w7\OneDrive University of Missouri\Desktop\ImportantFiles\Milestone4\backend\c_backend_directory_structure.json"
try:
analyze_backend_directory(backend_path, output_path)
print(f"Directory structure analysis complete. Output saved to {output_path}")
except Exception as e:
print(f"Error during analysis: {str(e)}")
if __name__ == "__main__":
main()