fix:修改敏感数据
This commit is contained in:
27
main.py
27
main.py
@@ -16,6 +16,7 @@ from rich.table import Table
|
||||
from config.config import load_config
|
||||
from utils.agent_utils import generate_comment
|
||||
from utils.font_utils import install_fonts_from_directory
|
||||
from utils.image_utils import find_image_path
|
||||
from utils.pef_utils import batch_convert_folder
|
||||
from utils.pptx_utils import replace_text_in_slide, replace_picture
|
||||
|
||||
@@ -112,31 +113,39 @@ def generate_report():
|
||||
# --- 页面 3 ---
|
||||
student_image_folder = os.path.join(config["image_folder"], name)
|
||||
if os.path.exists(student_image_folder):
|
||||
me_image = os.path.join(student_image_folder, "me_image.jpg")
|
||||
me_image_path = find_image_path(student_image_folder, "me_image")
|
||||
# 构造信息字典供 helper 使用
|
||||
info_dict = {
|
||||
"name": name, "english_name": english_name, "sex": sex,
|
||||
"birthday": birthday, "zodiac": zodiac, "friend": friend,
|
||||
"hobby": hobby, "game": game, "food": food
|
||||
}
|
||||
replace_three_page(prs, info_dict, me_image)
|
||||
replace_three_page(prs, info_dict, me_image_path)
|
||||
else:
|
||||
logger.warning(f"错误: 学生图片文件夹不存在 {student_image_folder}")
|
||||
|
||||
# --- 页面 4 ---
|
||||
class_image_path = os.path.join(config["image_folder"], config["class_name"] + ".jpg")
|
||||
class_image_path = find_image_path(config["image_folder"], config["class_name"])
|
||||
if os.path.exists(class_image_path):
|
||||
replace_four_page(prs, class_image_path)
|
||||
else:
|
||||
logger.warning(f"错误: 班级图片文件不存在 {class_image_path}")
|
||||
# 原逻辑中如果班级图片不存在会 continue 跳过保存,这里保持一致
|
||||
continue
|
||||
|
||||
# --- 页面 5 ---
|
||||
# --- 页面 5 ---
|
||||
if os.path.exists(student_image_folder):
|
||||
image1 = os.path.join(student_image_folder, "1.jpg")
|
||||
image2 = os.path.join(student_image_folder, "2.jpg") # 注意:原代码逻辑也是两张一样的图
|
||||
replace_five_page(prs, image1, image2)
|
||||
img1_path = find_image_path(student_image_folder, "1")
|
||||
img2_path = find_image_path(student_image_folder, "2")
|
||||
# 逻辑优化:
|
||||
# 情况A: 两张都找到了 -> 正常插入
|
||||
if img1_path and img2_path:
|
||||
replace_five_page(prs, img1_path, img2_path)
|
||||
|
||||
# 情况B: 只找到了 1 -> 两张图都用 1 (避免报错)
|
||||
elif img1_path and not img2_path:
|
||||
replace_five_page(prs, img1_path, img1_path)
|
||||
# 情况C: 一张都没找到
|
||||
else:
|
||||
logger.warning(f"⚠️ 警告: {name} 缺少生活照片 (1.jpg/png 或 2.jpg/png)[/]")
|
||||
else:
|
||||
logger.warning(f"错误: 学生图片文件夹不存在 {student_image_folder}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user