()
| 29 | |
| 30 | |
| 31 | def 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 | |
| 57 | if __name__ == '__main__': |
no test coverage detected