Skip to content

Commit 92b7bfd

Browse files
author
odoo
committed
feat: Add line counting and module analysis script for records_management
1 parent 1d5ff96 commit 92b7bfd

File tree

2 files changed

+95
-2
lines changed

2 files changed

+95
-2
lines changed

count_lines.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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)

records_management/data/products.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<!-- Product Template for Document Storage Box -->
55
<record id="product_template_box" model="product.template">
66
<field name="name">Document Storage Box</field>
7-
<field name="type">product</field>
7+
<field name="type">storable</field>
88
<field name="categ_id" ref="product.product_category_all"/>
99
<field name="default_code">REC-BOX</field>
1010
<field name="list_price">15.00</field>
@@ -27,7 +27,7 @@
2727
<!-- Product Template for Document File -->
2828
<record id="product_template_file" model="product.template">
2929
<field name="name">Document File</field>
30-
<field name="type">product</field>
30+
<field name="type">storable</field>
3131
<field name="categ_id" ref="product.product_category_all"/>
3232
<field name="default_code">REC-FILE</field>
3333
<field name="list_price">5.00</field>

0 commit comments

Comments
 (0)