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

Function main

utils/update_shields.py:31–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29
30
31def main():
32 json_path = 'docs/ScriptsPath.json'
33 data = read_json(json_path)
34 scripts = data.get('scripts', [])
35 start_tag = "<!--SHIELDS-->"
36 end_tag = "<!--SHIELDS-END-->"
37 for script in scripts:
38 script_directory = script.get('directory', '')
39 cnfile_path = os.path.join(script_directory, "README.md")
40 olddescriptions = get_file_description(cnfile_path, start_tag, end_tag)
41 # 构建中文徽章信息比对olddescriptions
42 new_content = get_new_content(script_directory)
43 if olddescriptions + "\n" == new_content: # 换行符添加上,就这样了能用就行
44 continue
45 else:
46 print(f"----\033[94m[{script.get('name', '')}]\033[0m\033[92m 内容变化,执行替换\033[0m")
47 md_files = get_md_files(script_directory)
48 for md_file in md_files:
49 lang = extract_lang_code(md_file)
50 if lang is None:
51 lang = ""
52 file_path = os.path.join(script_directory, md_file)
53 new_content = get_new_content(script_directory, lang)
54 process_file(file_path, new_content, start_tag, end_tag, "head")
55
56
57if __name__ == '__main__':

Callers 1

update_shields.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