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

fixed odd orders

上级 c0b2eb69
...@@ -326,26 +326,30 @@ class TreeWalker: ...@@ -326,26 +326,30 @@ 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:
if "exercise_id" not in meta: content = f.read()
meta["exercise_id"] = uuid.uuid4().hex if content:
if "notebook_enable" not in meta: meta = json.loads(content)
meta["notebook_enable"] = self.default_notebook() if "exercise_id" not in meta:
if "source" not in meta: meta["exercise_id"] = uuid.uuid4().hex
meta["source"] = source if "notebook_enable" not in meta:
if "author" not in meta: meta["notebook_enable"] = self.default_notebook()
meta["author"] = user_name() if "source" not in meta:
if "type" not in meta: meta["source"] = source
meta["type"] = "code_options" if "author" not in meta:
else: meta["author"] = user_name()
meta = { if "type" not in meta:
"type": "code_options", meta["type"] = "code_options"
"author": user_name(), if meta is None:
"source": source, meta = {
"notebook_enable": self.default_notebook(), "type": "code_options",
"exercise_id": uuid.uuid4().hex "author": user_name(),
} "source": source,
"notebook_enable": self.default_notebook(),
"exercise_id": uuid.uuid4().hex
}
dump_json(meta_path, meta, True, True) dump_json(meta_path, meta, True, True)
def default_notebook(self): def default_notebook(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册