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

Function write_to_md_file_en

resources/weekly_workflow.py:354–383  ·  view source on GitHub ↗

生成英文版摘要文件,用于发布到Medium、Dev.to等英文博客平台 :param weekly_no: 期号 :param pub_date: 发布日期 :param en_weekly_file: 英文周刊文件路径

(weekly_no, pub_date, en_weekly_file)

Source from the content-addressed store, hash-verified

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 """
356 生成英文版摘要文件,用于发布到Medium、Dev.to等英文博客平台
357 :param weekly_no: 期号
358 :param pub_date: 发布日期
359 :param en_weekly_file: 英文周刊文件路径
360 """
361 # 从英文版文件中读取真正的内容和元数据
362 if os.path.exists(en_weekly_file):
363 en_content_meta = get_front_matter(en_weekly_file)
364 en_content_body = content_to_string(read_md(en_weekly_file))
365 else:
366 print(f"Warning: English weekly file not found: {en_weekly_file}")
367 return None
368
369 if en_content_meta:
370 en_content_meta['title'] = build_english_weekly_title(en_content_meta.get('title', ''), weekly_no)
371 en_content_meta['description'] = build_english_description(en_content_meta.get('description', ''))
372
373 # 生成英文版摘要文件
374 en_summary_dir = 'docs/en'
375 if not os.path.exists(en_summary_dir):
376 os.makedirs(en_summary_dir)
377
378 en_summary_file = os.path.join(en_summary_dir, f"{pub_date}-weekly.md")
379 print("Writing English version summary...")
380 with open(en_summary_file, 'w', encoding='utf-8') as f:
381 write_summary_content(f, en_content_meta, en_content_body, weekly_no, is_english=True)
382
383 return en_summary_file, en_content_meta
384
385def set_title(no):
386 """

Callers 1

process_weeklyFunction · 0.85

Calls 6

get_front_matterFunction · 0.85
write_summary_contentFunction · 0.85
content_to_stringFunction · 0.70
read_mdFunction · 0.70

Tested by

no test coverage detected