MCPcopy
hub / github.com/pluwen/awesome-testflight-link / renew_readme

Function renew_readme

scripts/utils.py:87–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85 return "".join(markdown)
86
87def renew_readme():
88 if not README_TEMPLATE_FILE.exists():
89 print(f"Error: Template file {README_TEMPLATE_FILE} not found")
90 return
91
92 links_data = load_links()
93
94 with open(README_TEMPLATE_FILE, 'r', encoding='utf-8') as f:
95 template = f.read()
96
97 content = template
98
99 # 从 links.json 生成平台内容
100 platform_map = {
101 "iOS_APPS": ("ios", "## iOS App List\n\n"),
102 "iPadOS_APPS": ("ipados", "## iPadOS App List\n\n"),
103 "macOS_APPS": ("macos", "## macOS App List\n\n"),
104 "tvOS_APPS": ("tvos", "## tvOS App List\n\n"),
105 "visionOS_APPS": ("visionos", "## visionOS App List\n\n"),
106 }
107
108 for placeholder, (table_name, heading) in platform_map.items():
109 platform_content = generate_platform_section(table_name, links_data)
110 # 只在有内容时才包含标题
111 if platform_content.strip():
112 content = content.replace(f"#{{{placeholder}}}", heading + platform_content)
113 else:
114 # 如果没有内容,只删除占位符
115 content = content.replace(f"#{{{placeholder}}}", "")
116
117 # 读取并插入 signup.md 文件内容
118 signup_file = DATA_DIR / "signup.md"
119 if signup_file.exists():
120 try:
121 with open(signup_file, 'r', encoding='utf-8') as f:
122 signup_content = f.read()
123 # 从第一个 # 开始提取内容(跳过文件头注释)
124 content = content.replace("#{SIGNUP_APPS}", signup_content)
125 except Exception as e:
126 print(f"[warn] Failed to read signup.md: {e}")
127 content = content.replace("#{SIGNUP_APPS}", "")
128 else:
129 content = content.replace("#{SIGNUP_APPS}", "")
130
131 with open(README_FILE, 'w', encoding='utf-8') as f:
132 f.write(content)

Callers 5

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls 2

load_linksFunction · 0.85

Tested by

no test coverage detected