diff --git a/.gitignore b/.gitignore index 9062b0df630c653b0d19c85a1d2d1a94af48547e..639a96ea0758a4ddab0033313534a0bb86a9d396 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,6 @@ fix_bug.py tools.py back_.md test.md -lanqiao.cpp \ No newline at end of file +lanqiao.cpp +*.iml +**/.idea/** \ No newline at end of file diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257-\345\237\272\347\241\200/30.k\345\200\215\345\214\272\351\227\264/solution.json" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257-\345\237\272\347\241\200/30.k\345\200\215\345\214\272\351\227\264/solution.json" index 2c04da66a4ff3f0e9ea2d35075061691f860aea4..bd07be8d0f06bb8223de74361d67c7898b06bdaf 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257-\345\237\272\347\241\200/30.k\345\200\215\345\214\272\351\227\264/solution.json" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257-\345\237\272\347\241\200/30.k\345\200\215\345\214\272\351\227\264/solution.json" @@ -1,6 +1,7 @@ { "type": "code_options", "author": "csdn.net", - "source": "solution.md.md", - "exercise_id": "d5ad2458a40a46daaf75bbb9291e6d4b" + "source": "solution.md", + "exercise_id": "d5ad2458a40a46daaf75bbb9291e6d4b", + "notebook_enable": true } \ No newline at end of file diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257-\345\237\272\347\241\200/37.\345\271\263\351\235\242\345\210\207\345\210\206/solution.json" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257-\345\237\272\347\241\200/37.\345\271\263\351\235\242\345\210\207\345\210\206/solution.json" index 7a2bc292ac076b099c5974b664b206e3212f7a59..a76aaa72196fa7031e87f93da2b479431b549a4a 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257-\345\237\272\347\241\200/37.\345\271\263\351\235\242\345\210\207\345\210\206/solution.json" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/1.\350\223\235\346\241\245\346\235\257-\345\237\272\347\241\200/37.\345\271\263\351\235\242\345\210\207\345\210\206/solution.json" @@ -1,6 +1,7 @@ { "type": "code_options", "author": "csdn.net", - "source": "solution.md.md", - "exercise_id": "e572003202d0462fa95f635381897624" + "source": "solution.md", + "exercise_id": "e572003202d0462fa95f635381897624", + "notebook_enable": true } \ No newline at end of file diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/3.\350\223\235\346\241\245\346\235\257-\351\200\222\345\275\222/7.\351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217/solution.json" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/3.\350\223\235\346\241\245\346\235\257-\351\200\222\345\275\222/7.\351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217/solution.json" index faf9dea584e914e5c667cad12ada5e53b0d375ae..27dfc114a8aa20b0f4b8f6a5502204af91f3fdcb 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/3.\350\223\235\346\241\245\346\235\257-\351\200\222\345\275\222/7.\351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217/solution.json" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/3.\350\223\235\346\241\245\346\235\257-\351\200\222\345\275\222/7.\351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217/solution.json" @@ -1,6 +1,6 @@ { "type": "code_options", "author": "csdn.net", - "source": "solution.md.md", + "source": "solution.md", "exercise_id": "c29652154669434cb71e4f036b690fef" } \ No newline at end of file diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/5.\350\223\235\346\241\245\346\235\257-\346\250\241\346\213\237/13.\347\201\265\350\203\275\344\274\240\350\276\223/solution.json" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/5.\350\223\235\346\241\245\346\235\257-\346\250\241\346\213\237/13.\347\201\265\350\203\275\344\274\240\350\276\223/solution.json" index e4643b174eac0bdc2b0ee872abe073bafe8e0589..30f0e30a72ca54ec780d4dec878822afe13e6e83 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/5.\350\223\235\346\241\245\346\235\257-\346\250\241\346\213\237/13.\347\201\265\350\203\275\344\274\240\350\276\223/solution.json" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/5.\350\223\235\346\241\245\346\235\257-\346\250\241\346\213\237/13.\347\201\265\350\203\275\344\274\240\350\276\223/solution.json" @@ -1,6 +1,7 @@ { "type": "code_options", "author": "csdn.net", - "source": "solution.md.md", - "exercise_id": "a7672a561bd14ce5ba8bca21c4074683" + "source": "solution.md", + "exercise_id": "a7672a561bd14ce5ba8bca21c4074683", + "notebook_enable": true } \ No newline at end of file diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/5.\350\223\235\346\241\245\346\235\257-\346\250\241\346\213\237/16.\344\270\211\344\275\223\346\224\273\345\207\273/solution.json" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/5.\350\223\235\346\241\245\346\235\257-\346\250\241\346\213\237/16.\344\270\211\344\275\223\346\224\273\345\207\273/solution.json" index 0cf263cc334525a8b9b821bdb2b69c9ba5e005be..cdb1934232cb4faed39063aa50b6839e6c3aa64d 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/5.\350\223\235\346\241\245\346\235\257-\346\250\241\346\213\237/16.\344\270\211\344\275\223\346\224\273\345\207\273/solution.json" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/5.\350\223\235\346\241\245\346\235\257-\346\250\241\346\213\237/16.\344\270\211\344\275\223\346\224\273\345\207\273/solution.json" @@ -1,6 +1,7 @@ { "type": "code_options", "author": "csdn.net", - "source": "solution.md.md", - "exercise_id": "4db03bcefa5649d19f4dd5fe293221ab" + "source": "solution.md", + "exercise_id": "4db03bcefa5649d19f4dd5fe293221ab", + "notebook_enable": true } \ No newline at end of file diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/3.\350\243\205\351\245\260\347\217\240/solution.json" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/3.\350\243\205\351\245\260\347\217\240/solution.json" index 9dc6d8d0ffa9fdfd7db4060bafd15762aac05d04..062f9078c1ade02da84e7a09a4ff7b9362be3d3f 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/3.\350\243\205\351\245\260\347\217\240/solution.json" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/3.\350\243\205\351\245\260\347\217\240/solution.json" @@ -1,6 +1,7 @@ { "type": "code_options", "author": "csdn.net", - "source": "solution.md.md", - "exercise_id": "8b374f1e3965460e97f165638222ab90" + "source": "solution.md", + "exercise_id": "8b374f1e3965460e97f165638222ab90", + "notebook_enable": true } \ No newline at end of file diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/5.\347\273\204\345\220\210\346\225\260\351\227\256\351\242\230/solution.json" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/5.\347\273\204\345\220\210\346\225\260\351\227\256\351\242\230/solution.json" index 16297d2e46a5269e5aba80ba3d519ec0438fab3d..3dc1cca13d6100aa7601fee7118cfb6ab73a2414 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/5.\347\273\204\345\220\210\346\225\260\351\227\256\351\242\230/solution.json" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/5.\347\273\204\345\220\210\346\225\260\351\227\256\351\242\230/solution.json" @@ -1,6 +1,7 @@ { "type": "code_options", "author": "csdn.net", - "source": "solution.md.md", - "exercise_id": "3c3985435f414d7f9a8bbdcf42a42d46" + "source": "solution.md", + "exercise_id": "3c3985435f414d7f9a8bbdcf42a42d46", + "notebook_enable": true } \ No newline at end of file diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/6.\347\263\226\346\236\234/solution.json" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/6.\347\263\226\346\236\234/solution.json" index 2a24ccc114c21b32668cdbf51733196e03beb172..d1b3106a77eb4c63dd78db78209906be6e44e0c7 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/6.\347\263\226\346\236\234/solution.json" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/6.\347\263\226\346\236\234/solution.json" @@ -1,6 +1,7 @@ { "type": "code_options", "author": "csdn.net", - "source": "solution.md.md", - "exercise_id": "3c7880dd590c4f7cbe182c2c00af0e5a" + "source": "solution.md", + "exercise_id": "3c7880dd590c4f7cbe182c2c00af0e5a", + "notebook_enable": true } \ No newline at end of file diff --git "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/8.\345\236\222\351\252\260\345\255\220/solution.json" "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/8.\345\236\222\351\252\260\345\255\220/solution.json" index 511f720d431efd3933756c476ada723e10e9fde9..9dcb788afdc1d7075fbff89c08133301971732e8 100644 --- "a/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/8.\345\236\222\351\252\260\345\255\220/solution.json" +++ "b/data/1.\347\256\227\346\263\225\345\210\235\351\230\266/7.\350\223\235\346\241\245\346\235\257-\345\212\250\346\200\201\350\247\204\345\210\222/8.\345\236\222\351\252\260\345\255\220/solution.json" @@ -1,6 +1,7 @@ { "type": "code_options", "author": "csdn.net", - "source": "solution.md.md", - "exercise_id": "6b4b68a3ead544a2a9640d9ca6f008b1" + "source": "solution.md", + "exercise_id": "6b4b68a3ead544a2a9640d9ca6f008b1", + "notebook_enable": true } \ No newline at end of file diff --git a/leetcode_helper.py b/leetcode_helper.py index f516e128dffebf5fdbafcbb14d19f5b83031b4bf..7f56ad2cc13ca5e6106b017d8f5cfeb96d309f85 100644 --- a/leetcode_helper.py +++ b/leetcode_helper.py @@ -5,6 +5,7 @@ import json import uuid import argparse import collections + parser = argparse.ArgumentParser() parser.add_argument("--run", type=str, help="Decide to run which function") args = parser.parse_args() @@ -26,6 +27,7 @@ def get_files_path(file_dir, filetype='.txt'): files_path.append(os.path.join(root, file)) return files_path + def leetcode_helper(): data_dir = 'data/3.算法高阶/1.leetcode' dailycode_exercises_dir = '/Users/zhangzc/Desktop/workplace/daily-code-data/data/input/dailycode/leetcode/exercises' @@ -40,10 +42,11 @@ def leetcode_helper(): assert os.path.isdir(dir) exercises_id = dir.split('/')[-1].split('_')[0] if 0 <= int(exercises_id) and int(exercises_id) < 100: - desc_src_path = os.path.join(os.path.join(dailycode_exercises_dir, exercises_id), '{}_desc.html'.format(exercises_id)) - cpp_code_src_path = os.path.join(os.path.join(dailycode_exercises_dir, exercises_id),'{}.cpp'.format(exercises_id)) - - + desc_src_path = os.path.join(os.path.join(dailycode_exercises_dir, exercises_id), + '{}_desc.html'.format(exercises_id)) + cpp_code_src_path = os.path.join(os.path.join(dailycode_exercises_dir, exercises_id), + '{}.cpp'.format(exercises_id)) + desc_dst_path = os.path.join(dir, 'desc.html') cpp_code_dst_path = os.path.join(dir, 'solution.cpp') @@ -58,10 +61,10 @@ def leetcode_helper(): if not os.path.exists(cpp_code_dst_path): open(cpp_code_dst_path, 'w', encoding='utf-8') - + if 100 <= int(exercises_id) and int(exercises_id) < 203: with open(cpp_code_dst_path, 'r', encoding='utf-8') as f: - cpp_code = f.read() + cpp_code = f.read() if cpp_code == '' and not os.path.exists(shell_code_dst_path) and not os.path.exists(sql_code_dst_path): print(cpp_code_dst_path) desc_src_path = os.path.join(crawer_leetcode_dir, str(int(exercises_id) + 1) + '.html') @@ -72,11 +75,11 @@ def leetcode_helper(): if os.path.exists(desc_src_path): shutil.copy(desc_src_path, desc_dst_path) - + else: pass # print("该路径不存在,请检查: {}".format(desc_src_path)) - + def leetcode_helper_delete_md(): data_dir = 'data/3.算法高阶/1.leetcode' @@ -101,6 +104,7 @@ def leetcode_helper_delete_md(): if leetcode_solution_md_data == template: os.remove(solution_md_path) + def leetcode_helper_update_md(): data_dir = 'data/3.算法高阶/1.leetcode' dirs_ = os.listdir(data_dir) @@ -130,6 +134,7 @@ def leetcode_helper_update_md(): with open(solution_md_path, 'w', encoding='utf-8') as f: f.write(solution_md_data) + def leetcode_helper_update_config(): data_dir = 'data/3.算法高阶/1.leetcode' dirs_ = os.listdir(data_dir) @@ -161,7 +166,7 @@ def leetcode_helper_update_config(): "type": "code_options", "author": "CSDN.net", "source": "solution.md", - "exercise_id":exercise_id, + "exercise_id": exercise_id, } solution_json = json.dumps(solution_json_data, ensure_ascii=False, indent=3) with open(solution_json_path, 'w', encoding='utf-8') as f: @@ -211,7 +216,6 @@ def count_exercises(): dst_exercises_ids = [i for i in range(200)] lacked_id = set(dst_exercises_ids) - set(exercises_ids) print(lacked_id) - def modify_config_and_dir_name(): @@ -237,7 +241,7 @@ def modify_config_and_dir_name(): # with open(config_path, 'r', encoding='utf-8') as f: # config_data = json.load(f) - config_data['node_id'] = "algorithm-" + uuid.uuid4().hex + config_data['node_id'] = "algorithm-" + uuid.uuid4().hex config_data['keywords'] = ["leetcode", title] config_data['children'] = [] config_data['export'] = ['solution.json'] @@ -249,10 +253,7 @@ def modify_config_and_dir_name(): f.write(config_data_json) - - def modify_config_and_dir_name_new(): - dirs = ['data/2.算法中阶', 'data/3.算法高阶', 'data/1.算法初阶'] exercises_ids = [] for dir in dirs: @@ -262,7 +263,7 @@ def modify_config_and_dir_name_new(): leetcode_class_dir = os.path.join(dir, algo_floor_dir) if os.path.isdir(leetcode_class_dir): algo_floor_dirs.append(leetcode_class_dir) - + for algo_floor_dir in algo_floor_dirs: exercises_dirs_ = os.listdir(algo_floor_dir) exercises_dirs = [] @@ -273,7 +274,7 @@ def modify_config_and_dir_name_new(): for idx, tem_dir in enumerate(exercises_dirs): config_path = os.path.join(tem_dir, 'config.json') solution_md_path = os.path.join(tem_dir, 'solution.md') - + if dir == "data/1.算法初阶": title = tem_dir.split('/')[-1].split('.')[-1] else: @@ -282,16 +283,16 @@ def modify_config_and_dir_name_new(): solution_md_data = f.read() if solution_md_data.find('# {}\n\n'.format(title)) == -1: solution_md_data = solution_md_data.replace('# {}'.format(title), '# {}\n'.format(title)) - + if solution_md_data.find('## aop\n\n') == -1: solution_md_data = solution_md_data.replace('## aop', '## aop\n') if solution_md_data.find('## 答案\n\n') == -1: solution_md_data = solution_md_data.replace('## 答案', '## 答案\n') - + if solution_md_data.find('## 选项\n\n') == -1: solution_md_data = solution_md_data.replace('## 选项', '## 选项\n') - + if solution_md_data.find('### before\n\n') == -1: solution_md_data = solution_md_data.replace('### before', '### before\n') @@ -300,15 +301,13 @@ def modify_config_and_dir_name_new(): if solution_md_data.find('\n\n```cpp') == -1: solution_md_data = solution_md_data.replace('```cpp', '\n```cpp') - + if solution_md_data.find('\n\n### ') == -1: solution_md_data = solution_md_data.replace('### ', '\n### ') print(tem_dir) with open(solution_md_path, 'w', encoding='utf-8') as f: f.write(solution_md_data) - - # with open(config_path, 'r', encoding='utf-8') as f: # config_data = json.load(f) @@ -320,9 +319,6 @@ def modify_config_and_dir_name_new(): # f.write(config_data_json) - - - def modify_back_up_dir_name(): # dirs = ['data/2.算法中阶', 'data/3.算法高阶'] # exercises_ids = [] @@ -344,7 +340,7 @@ def modify_back_up_dir_name(): new_dir_name = os.path.join(root_dir, new_dir_name) os.rename(algo_floor_dir, new_dir_name) print(new_dir_name) - + def leetcode_helper_add_sloutionjson(): data_dir = 'data_backup/1.leetcode' @@ -369,14 +365,13 @@ def leetcode_helper_add_sloutionjson(): "type": "code_options", "author": "CSDN.net", "source": "solution.md", - "exercise_id":exercise_id, + "exercise_id": exercise_id, } solution_json = json.dumps(solution_json_data, ensure_ascii=False, indent=2) with open(solution_json_path, 'w', encoding='utf-8') as f: f.write(solution_json) - def fix_bug(): data_dir = 'data_backup/1.leetcode' dirs_ = os.listdir(data_dir) @@ -387,7 +382,7 @@ def fix_bug(): dirs.append(dir) for dir in dirs: assert os.path.isdir(dir) - + solution_md_path = os.path.join(dir, 'solution.md') if not os.path.exists(solution_md_path): continue @@ -398,16 +393,16 @@ def fix_bug(): # print(title) solution_md_data = solution_md_data.replace('# 两数之和', '# {}'.format(title)) if solution_md_data.find('# {}\n\n'.format(title)) == -1: - solution_md_data = solution_md_data.replace('# {}'.format(title), '# {}\n'.format(title)) + solution_md_data = solution_md_data.replace('# {}'.format(title), '# {}\n'.format(title)) if solution_md_data.find('## aop\n\n') == -1: solution_md_data = solution_md_data.replace('## aop', '## aop\n') if solution_md_data.find('## 答案\n\n') == -1: solution_md_data = solution_md_data.replace('## 答案', '## 答案\n') - + if solution_md_data.find('\n\n## 选项\n\n') == -1: solution_md_data = solution_md_data.replace('## 选项', '\n## 选项\n') - + if solution_md_data.find('### before\n\n') == -1: solution_md_data = solution_md_data.replace('### before', '### before\n') @@ -416,20 +411,19 @@ def fix_bug(): if solution_md_data.find('A\n\n```cpp') == -1: solution_md_data = solution_md_data.replace('A\n```cpp', 'A\n\n```cpp') - + if solution_md_data.find('B\n\n```cpp') == -1: solution_md_data = solution_md_data.replace('B\n```cpp', 'B\n\n```cpp') if solution_md_data.find('C\n\n```cpp') == -1: solution_md_data = solution_md_data.replace('C\n```cpp', 'C\n\n```cpp') print(dir) - + if solution_md_data.find('\n\n### ') == -1: solution_md_data = solution_md_data.replace('### ', '\n### ') with open(solution_md_path, 'w', encoding='utf-8') as f: f.write(solution_md_data) - def add_color_for_special_exercises(): count = 0 @@ -442,7 +436,7 @@ def add_color_for_special_exercises(): leetcode_class_dir = os.path.join(dir, algo_floor_dir) if os.path.isdir(leetcode_class_dir): algo_floor_dirs.append(leetcode_class_dir) - + for algo_floor_dir in algo_floor_dirs: exercises_dirs_ = os.listdir(algo_floor_dir) exercises_dirs = [] @@ -453,7 +447,7 @@ def add_color_for_special_exercises(): for idx, tem_dir in enumerate(exercises_dirs): config_path = os.path.join(tem_dir, 'config.json') solution_md_path = os.path.join(tem_dir, 'solution.md') - count+=1 + count += 1 print(solution_md_path) with open(solution_md_path, 'r', encoding='utf-8') as f: solution_md_data = f.read() @@ -461,10 +455,8 @@ def add_color_for_special_exercises(): solution_md_data = solution_md_data.replace('错误', '错误') with open(solution_md_path, 'w', encoding='utf-8') as f: f.write(solution_md_data) - - print('当前已有 {} 道习题'.format(count)) - + print('当前已有 {} 道习题'.format(count)) def add_solution_md_template_for_lanqiao(): @@ -477,7 +469,7 @@ def add_solution_md_template_for_lanqiao(): dirs.append(dir) for dir in dirs: assert os.path.isdir(dir) - + solution_md_path = os.path.join(dir, 'solution.md') solution_json_path = os.path.join(dir, 'solution.json') @@ -502,11 +494,11 @@ def add_solution_md_template_for_lanqiao(): if not os.path.exists(solution_json_path): exercise_id = uuid.uuid4().hex solution_json_data = { - "type": "code_options", - "author": "CSDN.net", - "source": "solution.md", - "exercise_id": exercise_id - } + "type": "code_options", + "author": "CSDN.net", + "source": "solution.md", + "exercise_id": exercise_id + } solution_json_data_json = json.dumps(solution_json_data, ensure_ascii=False, indent=2) with open(solution_json_path, 'w', encoding='utf-8') as f: f.write(solution_json_data_json) @@ -527,7 +519,7 @@ def check_exercises_is_duplicate(): leetcode_class_dir = os.path.join(dir, algo_floor_dir) if os.path.isdir(leetcode_class_dir): algo_floor_dirs.append(leetcode_class_dir) - + for algo_floor_dir in algo_floor_dirs: exercises_dirs_ = os.listdir(algo_floor_dir) exercises_dirs = [] @@ -554,7 +546,7 @@ def add_config_export(): leetcode_class_dir = os.path.join(dir, algo_floor_dir) if os.path.isdir(leetcode_class_dir): algo_floor_dirs.append(leetcode_class_dir) - + for algo_floor_dir in algo_floor_dirs: exercises_dirs_ = os.listdir(algo_floor_dir) exercises_dirs = [] @@ -583,7 +575,7 @@ def add_config_export_for_lanqiao_backup(): dirs.append(dir) for dir in dirs: assert os.path.isdir(dir) - + config_path = os.path.join(dir, 'config.json') print(config_path) with open(config_path, 'r', encoding='utf-8') as f: @@ -606,7 +598,7 @@ def fixbug_for_md(): leetcode_class_dir = os.path.join(dir, algo_floor_dir) if os.path.isdir(leetcode_class_dir): algo_floor_dirs.append(leetcode_class_dir) - + for algo_floor_dir in algo_floor_dirs: exercises_dirs_ = os.listdir(algo_floor_dir) exercises_dirs = [] @@ -624,8 +616,6 @@ def fixbug_for_md(): f.write(solution_md_data) - - if helper_function == 'count_tag_class': count_tag_class() if helper_function == 'count_exercises': @@ -633,50 +623,11 @@ if helper_function == 'count_exercises': if helper_function == 'modify_back_up_dir_name': modify_back_up_dir_name() - - # add_solution_md_template_for_lanqiao() # add_color_for_special_exercises() - - - -def remove_unse_md_file(): - count = 0 - - dirs = ['data/2.算法中阶', 'data/3.算法高阶', 'data/1.算法初阶'] - exercises_ids = [] - for dir in dirs: - dirs_ = os.listdir(dir) - algo_floor_dirs = [] - for algo_floor_dir in dirs_: - leetcode_class_dir = os.path.join(dir, algo_floor_dir) - if os.path.isdir(leetcode_class_dir): - algo_floor_dirs.append(leetcode_class_dir) - - for algo_floor_dir in algo_floor_dirs: - exercises_dirs_ = os.listdir(algo_floor_dir) - exercises_dirs = [] - for exercises_dir_ in exercises_dirs_: - exercises_dir = os.path.join(algo_floor_dir, exercises_dir_) - if os.path.isdir(exercises_dir): - exercises_dirs.append(exercises_dir) - for idx, tem_dir in enumerate(exercises_dirs): - - desc_md_path = os.path.join(tem_dir, 'desc.md') - print(desc_md_path) - if os.path.exists(desc_md_path): - os.remove(desc_md_path) - - -remove_unse_md_file() - - - # check_exercises_is_duplicate() # leetcode_helper_update_md() # leetcode_helper_update_config() - - diff --git a/main.py b/main.py index 11e4a8a4e6464eee33da20fcd968655b899681bf..498b4969959948487a717b0047fb3df54d2fc05b 100644 --- a/main.py +++ b/main.py @@ -5,5 +5,3 @@ if __name__ == '__main__': walker = TreeWalker("data", "algorithm", "Algorithm") walker.walk() - math = MathWalker('data') - math.walk()