提交 e19310cf 编写于 作者: ccat's avatar ccat

Merge branch 'dev/refactor' into 'master'

dev(hansbug): refactor the code && fix the bug on encoding

See merge request !1
......@@ -4,3 +4,4 @@
__pycache__
*.pyc
*.zip
.python-version
\ No newline at end of file
......@@ -4,7 +4,7 @@ import os
import re
import sys
import uuid
import re
import git
id_set = set()
......@@ -16,12 +16,21 @@ handler.setFormatter(formatter)
logger.addHandler(handler)
repo = git.Repo(".")
def user_name():
return repo.config_reader().get_value("user", "name")
_DEFAULT_ENCODING = 'utf-8'
def read_text(filepath):
with open(filepath, 'r', encoding='utf-8') as f:
return f.read()
def load_json(p):
with open(p, 'r') as f:
return json.loads(f.read())
return json.loads(read_text(p))
def dump_json(p, j, exist_ok=False, override=False):
......@@ -338,8 +347,7 @@ class TreeWalker:
_, mfile = os.path.split(meta_path)
meta = None
if os.path.exists(meta_path):
with open(meta_path) as f:
content = f.read()
content = read_text(meta_path)
if content:
meta = json.loads(content)
if "exercise_id" not in meta:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册