MCPcopy
hub / github.com/666ghj/BettaFish / main

Function main

regenerate_latest_html.py:288–334  ·  view source on GitHub ↗

主入口:读取最新章节、装订 IR 并渲染 HTML。 流程: 1) 找到最新的章节 run 目录并读取 manifest; 2) 加载章节并执行结构校验(仅警告); 3) 装订整本 IR,保存 IR 副本; 4) 渲染 HTML 并输出路径与统计信息。 返回: int: 0 表示成功,其余表示失败。

()

Source from the content-addressed store, hash-verified

286
287
288def main():
289 """
290 主入口:读取最新章节、装订 IR 并渲染 HTML。
291
292 流程:
293 1) 找到最新的章节 run 目录并读取 manifest;
294 2) 加载章节并执行结构校验(仅警告);
295 3) 装订整本 IR,保存 IR 副本;
296 4) 渲染 HTML 并输出路径与统计信息。
297
298 返回:
299 int: 0 表示成功,其余表示失败。
300 """
301 logger.info("🚀 使用最新的LLM章节重新装订并渲染HTML")
302
303 chapter_root = Path(settings.CHAPTER_OUTPUT_DIR)
304 latest_run = find_latest_run_dir(chapter_root)
305 if not latest_run:
306 return 1
307
308 report_id, metadata = load_manifest(latest_run)
309 if not report_id or metadata is None:
310 return 1
311
312 chapters = load_chapters(latest_run)
313 if not chapters:
314 logger.error("未找到章节JSON,无法装订")
315 return 1
316
317 validate_chapters(chapters)
318
319 document_ir = stitch_document(report_id, metadata, chapters)
320
321 timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
322 base_name = build_slug(
323 metadata.get("query") or metadata.get("title") or metadata.get("reportId") or report_id
324 )
325
326 ir_path = save_document_ir(document_ir, base_name, timestamp)
327 # 传入 ir_path,修复后的图表会自动保存到 IR 文件
328 html_path = render_html(document_ir, base_name, timestamp, ir_path=ir_path)
329
330 logger.info("")
331 logger.info("🎉 HTML装订与渲染完成")
332 logger.info(f"IR文件: {ir_path.resolve()}")
333 logger.info(f"HTML文件: {html_path.resolve()}")
334 return 0
335
336
337if __name__ == "__main__":

Callers 1

Calls 10

render_htmlFunction · 0.85
find_latest_run_dirFunction · 0.70
load_manifestFunction · 0.70
load_chaptersFunction · 0.70
validate_chaptersFunction · 0.70
stitch_documentFunction · 0.70
build_slugFunction · 0.70
save_document_irFunction · 0.70
errorMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected