MCPcopy
hub / github.com/chinesehuazhou/python-weekly / write_to_md_file

Function write_to_md_file

resources/weekly_workflow.py:327–352  ·  view source on GitHub ↗

生成两个版本的摘要文件: 1. 博客版本:使用完整版的元数据,但内容是摘要 2. Github版本:仅保留title和pubDate元数据,内容是摘要 :param weekly_no: 期号 :param content_meta: 元数据字典 :param md_body: 正文内容 :param pub_date: 发布日期 :param weekly_file: 周刊文件路径

(weekly_no, content_meta, md_body, pub_date, weekly_file)

Source from the content-addressed store, hash-verified

325 f.write(WECHAT_QR + "\n\n")
326
327def write_to_md_file(weekly_no, content_meta, md_body, pub_date, weekly_file):
328 """
329 生成两个版本的摘要文件:
330 1. 博客版本:使用完整版的元数据,但内容是摘要
331 2. Github版本:仅保留title和pubDate元数据,内容是摘要
332 :param weekly_no: 期号
333 :param content_meta: 元数据字典
334 :param md_body: 正文内容
335 :param pub_date: 发布日期
336 :param weekly_file: 周刊文件路径
337 """
338 # 1. 生成博客版本(完整元数据+摘要内容)
339 blog_dir = os.path.expanduser('~/Documents/GitHub/astro-blog/src/pages/posts')
340 if not os.path.exists(blog_dir):
341 os.makedirs(blog_dir)
342
343 blog_file = os.path.join(blog_dir, f"{pub_date}-weekly.md")
344 if not os.path.exists(blog_file):
345 print("Writing blog version summary...")
346 with open(blog_file, 'w', encoding="utf-8") as f:
347 write_summary_content(f, content_meta, md_body, weekly_no, weekly_file, True)
348
349 # 2. 生成Github版本(简化元数据+摘要内容)
350 print("Writing github version summary...")
351 with open(weekly_file, 'w', encoding='utf-8') as f:
352 write_summary_content(f, content_meta, md_body, weekly_no)
353
354def write_to_md_file_en(weekly_no, pub_date, en_weekly_file):
355 """

Callers 2

set_content_bodyFunction · 0.70
process_weeklyFunction · 0.70

Calls 1

write_summary_contentFunction · 0.85

Tested by

no test coverage detected