-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfinal_summary.py
More file actions
80 lines (70 loc) · 2.98 KB
/
final_summary.py
File metadata and controls
80 lines (70 loc) · 2.98 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
生成XVisual项目namespace XVisual添加情况总结
"""
import os
def check_files_with_namespace():
"""检查所有文件是否包含namespace XVisual"""
base_path = "XVisual"
# 检查include目录的.h文件
include_files = []
include_with_namespace = []
for root, dirs, files in os.walk(os.path.join(base_path, "include")):
for file in files:
if file.endswith('.h'):
file_path = os.path.join(root, file)
include_files.append(file_path)
try:
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
if 'namespace XVisual' in content:
include_with_namespace.append(file_path)
except:
pass
# 检查src目录的.cpp文件
src_files = []
src_with_namespace = []
for root, dirs, files in os.walk(os.path.join(base_path, "src")):
for file in files:
if file.endswith('.cpp'):
file_path = os.path.join(root, file)
src_files.append(file_path)
try:
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
if 'namespace XVisual' in content:
src_with_namespace.append(file_path)
except:
pass
print("=" * 80)
print("XVisual项目 namespace XVisual 添加情况总结")
print("=" * 80)
print(f"\n头文件 (.h):")
print(f" 总数: {len(include_files)}")
print(f" 已添加namespace XVisual: {len(include_with_namespace)}")
print(f" 未添加namespace XVisual: {len(include_files) - len(include_with_namespace)}")
if len(include_files) - len(include_with_namespace) > 0:
print(f"\n未添加namespace的头文件:")
for f in include_files:
if f not in include_with_namespace:
print(f" - {f}")
print(f"\n源文件 (.cpp):")
print(f" 总数: {len(src_files)}")
print(f" 已添加namespace XVisual: {len(src_with_namespace)}")
print(f" 未添加namespace XVisual: {len(src_files) - len(src_with_namespace)}")
if len(src_files) - len(src_with_namespace) > 0:
print(f"\n未添加namespace的源文件:")
for f in src_files:
if f not in src_with_namespace:
print(f" - {f}")
print(f"\n总计:")
total_files = len(include_files) + len(src_files)
total_with_namespace = len(include_with_namespace) + len(src_with_namespace)
print(f" 文件总数: {total_files}")
print(f" 已添加namespace: {total_with_namespace}")
print(f" 未添加namespace: {total_files - total_with_namespace}")
print(f" 完成率: {total_with_namespace / total_files * 100:.2f}%")
print("=" * 80)
if __name__ == "__main__":
check_files_with_namespace()