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

Function extract_weekly_no

resources/weekly_workflow.py:441–455  ·  view source on GitHub ↗

从文件内容中提取期号 :param file_path: 周刊文件路径 :return: 期号字符串

(file_path)

Source from the content-addressed store, hash-verified

439 await bot.send_message(chat_id=chat_id, text=text, parse_mode='Markdown', disable_web_page_preview=True)
440
441def extract_weekly_no(file_path):
442 """
443 从文件内容中提取期号
444 :param file_path: 周刊文件路径
445 :return: 期号字符串
446 """
447 print(f"Extracting weekly number from {file_path}")
448 with open(file_path, 'r', encoding="utf-8") as f:
449 content = f.read()
450 # 用正则从 title 字段提取期号,不依赖行号
451 match = re.search(r"title:\s*'[^']*?#(\d+)", content)
452 if match:
453 return match.group(1)
454 else:
455 raise ValueError("Invalid weekly no format: could not find issue number in title")
456
457def get_message(weekly_no, content_body):
458 """

Callers 2

split_and_generate_filesFunction · 0.70
process_weeklyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected