-
Notifications
You must be signed in to change notification settings - Fork 9
/
bsp_detail.py
35 lines (31 loc) · 1.35 KB
/
bsp_detail.py
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
import os
import pandas as pd
def check_files(root_dir, file_list):
data = []
folders_checked = set()
for projects in sconstruct_paths:
if projects not in folders_checked:
file_dict = {file: '✔' if os.path.isfile(os.path.join(projects, file)) else '' for file in file_list}
data.append({'Folder': projects, **file_dict})
folders_checked.add(projects)
df = pd.DataFrame(data)
return df
def find_sconstruct_paths(project_dir, exclude_paths):
sconstruct_paths = []
for root, dirs, files in os.walk(project_dir):
if all(exclude_path not in root for exclude_path in exclude_paths):
if 'SConstruct' in files:
sconstruct_paths.append(root)
return sconstruct_paths
def output_to_markdown(df, output_file):
with open(output_file, 'w', encoding='utf-8') as file:
file.write(df.to_markdown(index=False))
# 示例用法:
BSP_ROOT = os.path.join(".")
exclude_paths = ['templates', 'doc']
files_to_check = ['README.md','rtconfig.h', '.config','Kconfig', 'template.uvprojx','template.ewp', 'README.md', 'README_ZH.md', 'template.Uv2','template.uvproj']
sconstruct_paths = find_sconstruct_paths(BSP_ROOT, exclude_paths)
result_table = check_files(sconstruct_paths, files_to_check)
print(result_table)
output_file = 'output.md'
output_to_markdown(result_table, output_file)