发布f20251107 版本

This commit is contained in:
xsl
2025-11-06 21:28:34 +08:00
parent 02a005f5b1
commit 00aabfc6d9
73 changed files with 2397 additions and 2408 deletions
+38 -5
View File
@@ -28,8 +28,19 @@ def collect_png_from_subfolders(base_path=".", output_file="../example/src/main/
if os.path.isdir(item_path):
subfolders.append(item)
# 按文件夹名排序
subfolders.sort()
# 按文件夹名数字排序:纯数字的按数字大小排序,非纯数字的排在最后
def numeric_sort_key(folder_name):
"""
排序键函数:
- 如果是纯数字,按数字大小排序
- 如果不是纯数字,排在最后,按原字符串排序
"""
if folder_name.isdigit():
return (0, int(folder_name)) # 纯数字,类型标记为0,按数字排序
else:
return (1, folder_name) # 非纯数字,类型标记为1,排在后面
subfolders.sort(key=numeric_sort_key)
# 收集每个子文件夹中的PNG文件
all_png_files = {}
@@ -50,8 +61,22 @@ def collect_png_from_subfolders(base_path=".", output_file="../example/src/main/
if os.path.isfile(file_path) and file.lower().endswith('.png'):
png_filenames.append(file)
# 按文件名排序
png_filenames.sort()
# 按文件名数字排序:纯数字的按数字大小排序,非纯数字的排在最后
def png_numeric_sort_key(filename):
"""
PNG文件名排序键函数:
- 如果是纯数字(去掉.png后缀后),按数字排序
- 如果不是纯数字,排在最后,按原字符串排序
"""
# 移除.png后缀
name_without_ext = os.path.splitext(filename)[0]
# 如果是纯数字,按数字排序
if name_without_ext.isdigit():
return (0, int(name_without_ext))
else:
return (1, filename)
png_filenames.sort(key=png_numeric_sort_key)
# 如果有PNG文件,添加到结果中
if png_filenames:
@@ -74,11 +99,19 @@ def collect_png_from_subfolders(base_path=".", output_file="../example/src/main/
print(f" 其中 {total_folders} 个文件夹包含PNG文件")
print(f" 总共找到 {total_files} 个PNG文件")
# 显示文件夹类型统计
numeric_folders = [f for f in all_png_files.keys() if f.isdigit()]
non_numeric_folders = [f for f in all_png_files.keys() if not f.isdigit()]
print(f" 数字文件夹: {len(numeric_folders)}")
print(f" 非数字文件夹: {len(non_numeric_folders)}")
# 显示找到的文件
if all_png_files:
print("\n找到的PNG文件:")
for folder, files in all_png_files.items():
print(f" {folder}/:")
folder_type = "数字" if folder.isdigit() else "非数字"
print(f" {folder}/ ({folder_type}):")
for filename in files:
print(f" - {filename}")