MCPcopy
hub / github.com/ChinaGodMan/UserScripts / main

Function main

utils/update_help.py:17–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15
16
17def main():
18 json_path = 'docs/ScriptsPath.json'
19 data = read_json(json_path)
20 scripts = data.get('scripts', [])
21 start_tag = "<!--HELP-->"
22 end_tag = "<!--HELP-END-->"
23 new_content = get_new_content()
24 for script in scripts:
25 script_directory = script.get('directory', '')
26 cnfile_path = os.path.join(script_directory, "README.md")
27 olddescriptions = get_file_description(cnfile_path, start_tag, end_tag)
28 if olddescriptions + "\n" == new_content: # 换行符添加上,就这样了能用就行
29 continue
30 else:
31 print(f"----\033[94m[{script.get('name', '')}]\033[0m\033[92m 内容变化,执行替换\033[0m")
32 md_files = get_md_files(script_directory)
33 for md_file in md_files:
34 lang = extract_lang_code(md_file)
35 if lang is None:
36 lang = ""
37 file_path = os.path.join(script_directory, md_file)
38 new_content = get_new_content(lang)
39 process_file(file_path, new_content, start_tag, end_tag, "head")
40
41
42if __name__ == '__main__':

Callers 1

update_help.pyFile · 0.70

Calls 7

read_jsonFunction · 0.90
get_file_descriptionFunction · 0.90
get_md_filesFunction · 0.90
extract_lang_codeFunction · 0.90
process_fileFunction · 0.90
getMethod · 0.80
get_new_contentFunction · 0.70

Tested by

no test coverage detected