From 6fb7980218a679b5a080091926537e5f11618b2d Mon Sep 17 00:00:00 2001 From: Adrian Malacoda Date: Sat, 26 Nov 2016 23:54:05 -0600 Subject: [PATCH] make threads subdir under board so we can put an index.json there with board metadata --- tge/outputters/json.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tge/outputters/json.py b/tge/outputters/json.py index 1cabd6b..b5ca915 100644 --- a/tge/outputters/json.py +++ b/tge/outputters/json.py @@ -13,6 +13,10 @@ def output (data, destination): def output_forum (data, destination): os.makedirs(destination) + + with open(os.path.join(destination, "index.json"), "w") as out_file: + out_file.write(json.dumps({title: data.title}, indent=4)) + for category in data.categories: os.makedirs(os.path.join(destination, category.title)) for board in category.children: @@ -20,8 +24,12 @@ def output_forum (data, destination): def output_board (data, destination): os.makedirs(destination) + os.makedirs(os.path.join(destination, "threads")) + with open(os.path.join(destination, "index.json"), "w") as out_file: + out_file.write(json.dumps({"title": data.title}, indent=4)) + for thread in data.children: - output_thread(thread, os.path.join(destination, thread.title)) + output_thread(thread, os.path.join(destination, "threads", thread.title)) def output_thread (data, destination): with open(destination, "w") as out_file: