Update app.py
Browse files
app.py
CHANGED
@@ -645,7 +645,7 @@ def project_view_page():
|
|
645 |
st.sidebar.image("SimplifAI Logo Long.jpeg", use_container_width=True)
|
646 |
st.sidebar.title(f"Project: {st.session_state.current_project}")
|
647 |
if st.sidebar.button("Back to Project Staging"):
|
648 |
-
st.session_state.page = "
|
649 |
st.rerun()
|
650 |
if st.sidebar.button("Log Out"):
|
651 |
st.session_state.authenticated = False
|
@@ -660,19 +660,16 @@ def project_view_page():
|
|
660 |
# Calculate project metrics
|
661 |
user_folder = os.path.join("user_projects", st.session_state.username)
|
662 |
project_folder = os.path.join(user_folder, st.session_state.current_project)
|
663 |
-
|
664 |
# Count number of files
|
665 |
-
num_files = sum([len(files) for _, _, files in os.walk(project_folder)
|
666 |
|
667 |
# Count total lines of code in all text files
|
668 |
num_lines = 0
|
669 |
for root, _, files in os.walk(project_folder):
|
670 |
-
if ".git" in root:
|
671 |
-
continue # Skip .git directory
|
672 |
for file in files:
|
673 |
file_path = os.path.join(root, file)
|
674 |
try:
|
675 |
-
# Only include text files (e.g., .py, .txt, .json, etc.)
|
676 |
with open(file_path, 'r', encoding='utf-8') as f:
|
677 |
num_lines += sum(1 for _ in f)
|
678 |
except (UnicodeDecodeError, IsADirectoryError):
|
@@ -706,16 +703,17 @@ def project_view_page():
|
|
706 |
if st.session_state.show_file_structure:
|
707 |
st.write("File structure:")
|
708 |
for root, dirs, files in os.walk(project_folder):
|
709 |
-
if ".git" in root:
|
710 |
-
continue # Skip .git directory
|
711 |
level = root.replace(project_folder, "").count(os.sep)
|
712 |
indent = " " * 4 * level
|
713 |
|
|
|
714 |
if level == 0:
|
715 |
st.write(f"π {os.path.basename(root)}")
|
716 |
else:
|
717 |
with st.expander(f"{indent}π {os.path.basename(root)}"):
|
718 |
sub_indent = " " * 4 * (level + 1)
|
|
|
|
|
719 |
for file in files:
|
720 |
st.write(f"{sub_indent}π {file}")
|
721 |
|
|
|
645 |
st.sidebar.image("SimplifAI Logo Long.jpeg", use_container_width=True)
|
646 |
st.sidebar.title(f"Project: {st.session_state.current_project}")
|
647 |
if st.sidebar.button("Back to Project Staging"):
|
648 |
+
st.session_state.page = "project_staging" # Corrected navigation
|
649 |
st.rerun()
|
650 |
if st.sidebar.button("Log Out"):
|
651 |
st.session_state.authenticated = False
|
|
|
660 |
# Calculate project metrics
|
661 |
user_folder = os.path.join("user_projects", st.session_state.username)
|
662 |
project_folder = os.path.join(user_folder, st.session_state.current_project)
|
663 |
+
|
664 |
# Count number of files
|
665 |
+
num_files = sum([len(files) for _, _, files in os.walk(project_folder)])
|
666 |
|
667 |
# Count total lines of code in all text files
|
668 |
num_lines = 0
|
669 |
for root, _, files in os.walk(project_folder):
|
|
|
|
|
670 |
for file in files:
|
671 |
file_path = os.path.join(root, file)
|
672 |
try:
|
|
|
673 |
with open(file_path, 'r', encoding='utf-8') as f:
|
674 |
num_lines += sum(1 for _ in f)
|
675 |
except (UnicodeDecodeError, IsADirectoryError):
|
|
|
703 |
if st.session_state.show_file_structure:
|
704 |
st.write("File structure:")
|
705 |
for root, dirs, files in os.walk(project_folder):
|
|
|
|
|
706 |
level = root.replace(project_folder, "").count(os.sep)
|
707 |
indent = " " * 4 * level
|
708 |
|
709 |
+
# Display folders and files recursively
|
710 |
if level == 0:
|
711 |
st.write(f"π {os.path.basename(root)}")
|
712 |
else:
|
713 |
with st.expander(f"{indent}π {os.path.basename(root)}"):
|
714 |
sub_indent = " " * 4 * (level + 1)
|
715 |
+
for folder in dirs:
|
716 |
+
st.write(f"{sub_indent}π {folder}")
|
717 |
for file in files:
|
718 |
st.write(f"{sub_indent}π {file}")
|
719 |
|