|
| 1 | +#!/usr/bin/env python3 |
| 2 | +import os |
| 3 | +import glob |
| 4 | +from pathlib import Path |
| 5 | + |
| 6 | +def count_lines_in_file(file_path): |
| 7 | + """Count lines in a file""" |
| 8 | + try: |
| 9 | + with open(file_path, 'r', encoding='utf-8', errors='ignore') as f: |
| 10 | + return len(f.readlines()) |
| 11 | + except Exception as e: |
| 12 | + print(f"Error reading {file_path}: {e}") |
| 13 | + return 0 |
| 14 | + |
| 15 | +def analyze_module(module_path): |
| 16 | + """Analyze the records_management module""" |
| 17 | + if not os.path.exists(module_path): |
| 18 | + print(f"Module path not found: {module_path}") |
| 19 | + return |
| 20 | + |
| 21 | + print("🔍 RECORDS MANAGEMENT MODULE - CODE ANALYSIS") |
| 22 | + print("=" * 60) |
| 23 | + |
| 24 | + # File extensions to analyze |
| 25 | + extensions = { |
| 26 | + '*.py': '🐍 Python', |
| 27 | + '*.xml': '📄 XML', |
| 28 | + '*.csv': '📋 CSV', |
| 29 | + '*.js': '💻 JavaScript', |
| 30 | + '*.scss': '🎨 SCSS', |
| 31 | + '*.css': '🎨 CSS', |
| 32 | + '*.md': '📖 Markdown' |
| 33 | + } |
| 34 | + |
| 35 | + total_files = 0 |
| 36 | + total_lines = 0 |
| 37 | + file_stats = {} |
| 38 | + |
| 39 | + for pattern, description in extensions.items(): |
| 40 | + files = list(Path(module_path).rglob(pattern)) |
| 41 | + if files: |
| 42 | + file_count = len(files) |
| 43 | + line_count = sum(count_lines_in_file(f) for f in files) |
| 44 | + file_stats[description] = { |
| 45 | + 'files': file_count, |
| 46 | + 'lines': line_count, |
| 47 | + 'files_list': files |
| 48 | + } |
| 49 | + total_files += file_count |
| 50 | + total_lines += line_count |
| 51 | + |
| 52 | + # Print summary |
| 53 | + print(f"📁 TOTAL FILES: {total_files}") |
| 54 | + print(f"📏 TOTAL LINES: {total_lines:,}") |
| 55 | + print() |
| 56 | + |
| 57 | + # Print by file type |
| 58 | + print("📊 BREAKDOWN BY FILE TYPE:") |
| 59 | + print("-" * 40) |
| 60 | + for description, stats in file_stats.items(): |
| 61 | + print(f"{description}: {stats['files']} files, {stats['lines']:,} lines") |
| 62 | + |
| 63 | + print() |
| 64 | + print("📂 DETAILED FILE BREAKDOWN:") |
| 65 | + print("-" * 60) |
| 66 | + |
| 67 | + # Show individual files |
| 68 | + for description, stats in file_stats.items(): |
| 69 | + if stats['files'] > 0: |
| 70 | + print(f"\n{description} FILES:") |
| 71 | + for file_path in sorted(stats['files_list']): |
| 72 | + lines = count_lines_in_file(file_path) |
| 73 | + relative_path = os.path.relpath(file_path, module_path) |
| 74 | + print(f" 📄 {relative_path}: {lines:,} lines") |
| 75 | + |
| 76 | + # Find largest files |
| 77 | + print("\n🏆 TOP 10 LARGEST FILES:") |
| 78 | + print("-" * 40) |
| 79 | + all_files = [] |
| 80 | + for stats in file_stats.values(): |
| 81 | + for file_path in stats['files_list']: |
| 82 | + lines = count_lines_in_file(file_path) |
| 83 | + relative_path = os.path.relpath(file_path, module_path) |
| 84 | + all_files.append((relative_path, lines)) |
| 85 | + |
| 86 | + # Sort by line count and show top 10 |
| 87 | + all_files.sort(key=lambda x: x[1], reverse=True) |
| 88 | + for i, (file_path, lines) in enumerate(all_files[:10], 1): |
| 89 | + print(f" {i:2d}. {file_path}: {lines:,} lines") |
| 90 | + |
| 91 | +if __name__ == "__main__": |
| 92 | + module_path = "/workspaces/ssh-git-github.com-odoo-odoo.git-8.0/records_management" |
| 93 | + analyze_module(module_path) |
0 commit comments