提交 ce1d30c0 编写于 作者: HansBug's avatar HansBug 😆 提交者: ccat

dev(hansbug): refactor code format && rename requirement.txt -->...

dev(hansbug): refactor code format && rename requirement.txt --> requirements.txt && ignore .python-version
上级 88cc05c6
...@@ -4,3 +4,4 @@ ...@@ -4,3 +4,4 @@
__pycache__ __pycache__
*.pyc *.pyc
*.zip *.zip
.python-version
\ No newline at end of file
...@@ -4,7 +4,7 @@ import os ...@@ -4,7 +4,7 @@ import os
import re import re
import sys import sys
import uuid import uuid
import re
import git import git
id_set = set() id_set = set()
...@@ -16,12 +16,21 @@ handler.setFormatter(formatter) ...@@ -16,12 +16,21 @@ handler.setFormatter(formatter)
logger.addHandler(handler) logger.addHandler(handler)
repo = git.Repo(".") repo = git.Repo(".")
def user_name(): def user_name():
return repo.config_reader().get_value("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): def load_json(p):
with open(p, 'r') as f: return json.loads(read_text(p))
return json.loads(f.read())
def dump_json(p, j, exist_ok=False, override=False): def dump_json(p, j, exist_ok=False, override=False):
...@@ -338,8 +347,7 @@ class TreeWalker: ...@@ -338,8 +347,7 @@ class TreeWalker:
_, mfile = os.path.split(meta_path) _, mfile = os.path.split(meta_path)
meta = None meta = None
if os.path.exists(meta_path): if os.path.exists(meta_path):
with open(meta_path) as f: content = read_text(meta_path)
content = f.read()
if content: if content:
meta = json.loads(content) meta = json.loads(content)
if "exercise_id" not in meta: if "exercise_id" not in meta:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册