提交 c3d205d6 编写于 作者: M Mars Liu

fixed odd orders

上级 c0b2eb69
...@@ -326,8 +326,12 @@ class TreeWalker: ...@@ -326,8 +326,12 @@ class TreeWalker:
def ensure_exercises_meta(self, meta_path, source): def ensure_exercises_meta(self, meta_path, source):
_, mfile = os.path.split(meta_path) _, mfile = os.path.split(meta_path)
meta = None
if os.path.exists(meta_path): if os.path.exists(meta_path):
meta = load_json(meta_path) with open(meta_path) as f:
content = f.read()
if content:
meta = json.loads(content)
if "exercise_id" not in meta: if "exercise_id" not in meta:
meta["exercise_id"] = uuid.uuid4().hex meta["exercise_id"] = uuid.uuid4().hex
if "notebook_enable" not in meta: if "notebook_enable" not in meta:
...@@ -338,7 +342,7 @@ class TreeWalker: ...@@ -338,7 +342,7 @@ class TreeWalker:
meta["author"] = user_name() meta["author"] = user_name()
if "type" not in meta: if "type" not in meta:
meta["type"] = "code_options" meta["type"] = "code_options"
else: if meta is None:
meta = { meta = {
"type": "code_options", "type": "code_options",
"author": user_name(), "author": user_name(),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册