diff --git "a/data/1.toolchains\345\210\235\351\230\266/1.GIT\345\205\245\351\227\250/config.json" "b/data/1.toolchains\345\210\235\351\230\266/1.GIT\345\205\245\351\227\250/config.json" index 89f61889832c5b4eca3923c569e4a0824e1098a5..d6aaccbb632c8d997dd568a36cd437bf005e5b81 100644 --- "a/data/1.toolchains\345\210\235\351\230\266/1.GIT\345\205\245\351\227\250/config.json" +++ "b/data/1.toolchains\345\210\235\351\230\266/1.GIT\345\205\245\351\227\250/config.json" @@ -1,3 +1,5 @@ { - "keywords": [] + "keywords": [], + "node_id": "c-1cf412c0785c4269a2a4cc7634aa101b", + "title": "GIT入门" } \ No newline at end of file diff --git "a/data/1.toolchains\345\210\235\351\230\266/config.json" "b/data/1.toolchains\345\210\235\351\230\266/config.json" index 89f61889832c5b4eca3923c569e4a0824e1098a5..22e35068e43ff193c879b33e24e0099a9e839983 100644 --- "a/data/1.toolchains\345\210\235\351\230\266/config.json" +++ "b/data/1.toolchains\345\210\235\351\230\266/config.json" @@ -1,3 +1,5 @@ { - "keywords": [] + "keywords": [], + "node_id": "c-5995c3ccf1554d1ca4e48da52cf6aed9", + "title": "toolchains初阶" } \ No newline at end of file diff --git "a/data/2.toolchains\344\270\255\351\230\266/config.json" "b/data/2.toolchains\344\270\255\351\230\266/config.json" index 89f61889832c5b4eca3923c569e4a0824e1098a5..5c2bc98918b04a1ec0fb07711b6790356083a468 100644 --- "a/data/2.toolchains\344\270\255\351\230\266/config.json" +++ "b/data/2.toolchains\344\270\255\351\230\266/config.json" @@ -1,3 +1,5 @@ { - "keywords": [] + "keywords": [], + "node_id": "c-671b93fb441b44bd86020a6c5ecb689b", + "title": "toolchains中阶" } \ No newline at end of file diff --git "a/data/3.toolchains\351\253\230\351\230\266/config.json" "b/data/3.toolchains\351\253\230\351\230\266/config.json" index 89f61889832c5b4eca3923c569e4a0824e1098a5..f17c3d7499082748a5b7f8c7c780e1293dcaa9d1 100644 --- "a/data/3.toolchains\351\253\230\351\230\266/config.json" +++ "b/data/3.toolchains\351\253\230\351\230\266/config.json" @@ -1,3 +1,5 @@ { - "keywords": [] + "keywords": [], + "node_id": "c-60527be7abb340d39a1d4a4e780b402c", + "title": "toolchains高阶" } \ No newline at end of file diff --git a/data/config.json b/data/config.json new file mode 100644 index 0000000000000000000000000000000000000000..f201a93fa860a949a28bf8d1c91cdef048e62ae2 --- /dev/null +++ b/data/config.json @@ -0,0 +1,6 @@ +{ + "tree_name": "Toolchains", + "keywords": [], + "node_id": "c-9ae45d2c41cd4958a449b8f50a394fcc", + "title": "C" +} \ No newline at end of file diff --git a/data/tree.json b/data/tree.json new file mode 100644 index 0000000000000000000000000000000000000000..9911e4b8b964e8d5f637f0916c36585b66ed1b19 --- /dev/null +++ b/data/tree.json @@ -0,0 +1,37 @@ +{ + "Toolchains": { + "node_id": "c-9ae45d2c41cd4958a449b8f50a394fcc", + "keywords": [], + "children": [ + { + "toolchains初阶": { + "node_id": "c-5995c3ccf1554d1ca4e48da52cf6aed9", + "keywords": [], + "children": [ + { + "GIT入门": { + "node_id": "c-1cf412c0785c4269a2a4cc7634aa101b", + "keywords": [], + "children": [] + } + } + ] + } + }, + { + "toolchains中阶": { + "node_id": "c-671b93fb441b44bd86020a6c5ecb689b", + "keywords": [], + "children": [] + } + }, + { + "toolchains高阶": { + "node_id": "c-60527be7abb340d39a1d4a4e780b402c", + "keywords": [], + "children": [] + } + } + ] + } +} \ No newline at end of file diff --git a/src/tree.py b/src/tree.py index 0c64f2dd9d7e3a877c22e2dcbca26d1f6526e43d..ba3287e6e837316c3ec263822d6b503df4bff6fd 100644 --- a/src/tree.py +++ b/src/tree.py @@ -21,7 +21,7 @@ def dump_json(p, j, exist_ok=False, override=False): print(f"{p} already exist") sys.exit(0) - with open(p, 'w') as f: + with open(p, 'w+') as f: f.write(json.dumps(j, indent=2, ensure_ascii=False)) @@ -117,7 +117,7 @@ def gen_tree(data_path): cfg_path = os.path.join(data_path, 'config.json') cfg = load_json(cfg_path) if ensure_node_id(cfg): - dump_json(cfg_path, cfg) + dump_json(cfg_path, cfg, exist_ok=True, override=True) if ensure_title(cfg, cfg_path): cfg["title"] = "C"