MCPcopy Index your code
hub / github.com/ChinaGodMan/UserScripts / insert_into_meta

Function insert_into_meta

utils/userscript_localization_tool.py:25–37  ·  view source on GitHub ↗
(file_path, content, file_lock)

Source from the content-addressed store, hash-verified

23
24# 在meta中插入翻译的区域化
25def insert_into_meta(file_path, content, file_lock):
26 with file_lock:
27 with open(file_path, 'r', encoding='utf-8') as file:
28 lines = file.readlines()
29 for i, line in enumerate(lines):
30 if "==UserScript==" in line:
31 lines.insert(i + 1, content + "\n")
32 break
33 else:
34 return
35 with open(file_path, 'w', encoding='utf-8', newline='\n') as file:
36 file.writelines(lines)
37 print(f"\033[34m内容已插入到 '{file_path}' 中 \033[0m")
38
39
40# 读取文件并查找中文简介

Callers 1

translate_taskFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected