提交 7c76b1d2 编写于 作者: M Mars Liu

for merge

上级 8f95621a
......@@ -20,3 +20,5 @@ tools.py
back_.md
test.md
lanqiao.cpp
*.iml
**/.idea/**
\ No newline at end of file
{
"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
{
"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
{
"type": "code_options",
"author": "csdn.net",
"source": "solution.md.md",
"source": "solution.md",
"exercise_id": "c29652154669434cb71e4f036b690fef"
}
\ No newline at end of file
{
"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
{
"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
{
"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
{
"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
{
"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
{
"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
......@@ -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,9 +42,10 @@ 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')
......@@ -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:
......@@ -213,7 +218,6 @@ def count_exercises():
print(lacked_id)
def modify_config_and_dir_name():
# dirs = ['data/2.算法中阶', 'data/3.算法高阶']
# exercises_ids = []
......@@ -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:
......@@ -308,8 +309,6 @@ def modify_config_and_dir_name_new():
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)
# del config_data['title']
......@@ -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 = []
......@@ -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)
......@@ -429,7 +424,6 @@ def fix_bug():
f.write(solution_md_data)
def add_color_for_special_exercises():
count = 0
......@@ -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()
......@@ -465,8 +459,6 @@ def add_color_for_special_exercises():
print('当前已有 {} 道习题'.format(count))
def add_solution_md_template_for_lanqiao():
data_dir = 'data_backup/3.蓝桥杯'
dirs_ = os.listdir(data_dir)
......@@ -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()
......@@ -5,5 +5,3 @@ if __name__ == '__main__':
walker = TreeWalker("data", "algorithm", "Algorithm")
walker.walk()
math = MathWalker('data')
math.walk()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册