JSenkCC commited on
Commit
6c7a8f5
·
verified ·
1 Parent(s): 8f2537a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -654,6 +654,26 @@ def project_view_page():
654
  st.subheader(f"Project: {st.session_state.current_project}")
655
  st.write("Manage your project and explore its files.")
656
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
657
  # Buttons for documentation functionality
658
  if st.button("Generate Documentation"):
659
  st.session_state.page = "generate_documentation"
 
654
  st.subheader(f"Project: {st.session_state.current_project}")
655
  st.write("Manage your project and explore its files.")
656
 
657
+ # Calculate number of files and lines of code
658
+ file_count = 0
659
+ total_lines = 0
660
+
661
+ for root, dirs, files in os.walk(project_folder):
662
+ file_count += len(files)
663
+ for file in files:
664
+ file_path = os.path.join(root, file)
665
+ try:
666
+ with open(file_path, "r", encoding="utf-8") as f:
667
+ total_lines += sum(1 for line in f)
668
+ except (UnicodeDecodeError, FileNotFoundError):
669
+ # Skip non-text files or files that can't be read
670
+ continue
671
+
672
+ # Display project metrics
673
+ st.write("### Project Metrics")
674
+ st.metric(label="Total Files", value=file_count)
675
+ st.metric(label="Lines of Code", value=total_lines)
676
+
677
  # Buttons for documentation functionality
678
  if st.button("Generate Documentation"):
679
  st.session_state.page = "generate_documentation"