提交 01430978 编写于 作者: 每日一练社区's avatar 每日一练社区

update dailycode pipline

上级 eb727b9e
......@@ -79,9 +79,9 @@ def classify_exercises():
solution_json_data['exercise_id'] = uuid.uuid4().hex
solution_md_data = f"# {question_title}\n\n{question_content}\n\n## template\n\n```{language}\n{answer}\n```\n\n## 答案\n\n```{language}\n\n```\n\n## 选项\n\n### A\n\n```{language}\n\n```\n\n### B\n\n```{language}\n\n```\n\n### C\n\n```{language}\n\n```"
print(solution_md_data)
print(config_data)
print(solution_json_data)
# print(solution_md_data)
# print(config_data)
# print(solution_json_data)
if difficulty == '简单':
......@@ -103,25 +103,31 @@ def classify_exercises():
language_dir = ''
sys.exit("语言类型异常")
dst_dir = os.path.join(root_dir, language_dir)
count +=1
dst_dir = os.path.join(dst_dir, str(count) + '.exercises')
dir_list_ = os.listdir(dst_dir)
dir_list = []
for i in dir_list_:
if os.path.isdir(i):
dir_list.append(i)
number = len(dir_list) + 1
dst_dir = os.path.join(dst_dir, str(number) + '.exercises')
solution_json_path = os.path.join(dst_dir, 'solution.json')
solution_md_path = os.path.join(dst_dir, 'solution.md')
config_path = os.path.join(dst_dir, 'config.json')
print(count)
print(dst_dir)
print(solution_json_path)
print(solution_md_path)
print(config_path)
# if not os.path.exists(dst_dir):
# os.mkdir(dst_dir)
# dump_json(solution_json_path, solution_json_data)
# dump_json(config_path, config_data)
# with open(solution_md_path, 'w', encoding='utf-8') as f:
# f.write(solution_md_data)
if not os.path.exists(dst_dir):
os.mkdir(dst_dir)
dump_json(solution_json_path, solution_json_data)
dump_json(config_path, config_data)
with open(solution_md_path, 'w', encoding='utf-8') as f:
f.write(solution_md_data)
def classify_leetcode():
leetcode_dir = 'data_backup/leetcode'
......@@ -195,13 +201,13 @@ def classify_leetcode():
print(solution_json_data)
print(solution_md_data)
# if not os.path.exists(dst_dir):
# os.mkdir(dst_dir)
# dump_json(solution_json_path, solution_json_data)
# dump_json(config_path, config_data)
# with open(solution_md_path, 'w', encoding='utf-8') as f:
# f.write(solution_md_data)
if not os.path.exists(dst_dir):
os.mkdir(dst_dir)
dump_json(solution_json_path, solution_json_data)
dump_json(config_path, config_data)
with open(solution_md_path, 'w', encoding='utf-8') as f:
f.write(solution_md_data)
# classify_exercises()
classify_exercises()
classify_leetcode()
\ No newline at end of file
# classify_leetcode()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册