die TEFBOGEN sind korrigiert.

This commit is contained in:
2025-09-23 10:26:59 +02:00
parent ea678d7a23
commit 62e46562fc
89 changed files with 2930 additions and 2038 deletions
@@ -5,6 +5,7 @@ import re
import xml.etree.ElementTree as ET
from xml.dom import minidom
import argparse
import shutil
def analyze_and_normalize_path(d, path_type, path_id=""):
"""Strictly normalize path direction and generate detailed report"""
@@ -337,7 +338,18 @@ def optimize_svg(input_path, output_path):
print(f"\nProcessing error: {str(e)}")
print("="*60)
return False
def clear_output_dir(path: str):
os.makedirs(path, exist_ok=True)
for filename in os.listdir(path):
file_path = os.path.join(path, filename)
try:
if os.path.isdir(file_path):
shutil.rmtree(file_path) # 删除目录
elif os.path.isfile(file_path) or os.path.islink(file_path):
os.unlink(file_path) # 删除文件或符号链接
except Exception as e:
print(f"Failed to delete {file_path}. Reason: {e}")
def batch_process_svgs(input_dir, output_dir):
if not os.path.exists(output_dir):
@@ -416,7 +428,8 @@ if __name__ == '__main__':
print(f"file {filename} does not exist")
if in_dir:
"""Batch process SVG files"""
# 清空 output_dir
clear_output_dir(out_dir)
batch_process_svgs(in_dir, out_dir)
else: