From b9d2545880c112c621334ec0b7793d1ec32df1c1 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Fri, 16 Dec 2022 19:04:16 +0800 Subject: [PATCH] feat: txt release demo --- src/release/txt.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 src/release/txt.py diff --git a/src/release/txt.py b/src/release/txt.py new file mode 100755 index 0000000..0fc9de3 --- /dev/null +++ b/src/release/txt.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import json + +rootPath = os.path.join( + os.path.dirname(os.path.realpath(__file__)), '../../' +) +dataPath = os.path.join(rootPath, './release/') +metadataFile = os.path.join(rootPath, './assets/metadata.json') + + +def loadData(jsonName: str) -> dict: + content = json.loads(open( + os.path.join(dataPath, '%s.json' % jsonName) + ).read()) + metadata = json.loads(open(metadataFile).read()) + return { + 'metadata': metadata, + 'content': content, + } + + +def releaseChapter(caption: str, content: list) -> str: + return '\n\n'.join([caption] + content) + + +data = loadData('rc-4') +c = data['content'] +for (c, dat) in c.items(): + print(releaseChapter(c, dat)) + break