()
| 15 | |
| 16 | |
| 17 | def 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 | |
| 42 | if __name__ == '__main__': |
no test coverage detected