From 5168b2ab37a6d226a99c96a339c9887d92d83ddf Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Thu, 29 Dec 2022 21:52:55 +0800 Subject: [PATCH] update: txt release process --- src/release/to_txt.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) mode change 100644 => 100755 src/release/to_txt.py diff --git a/src/release/to_txt.py b/src/release/to_txt.py old mode 100644 new mode 100755 index 8828001..bd717cc --- a/src/release/to_txt.py +++ b/src/release/to_txt.py @@ -3,6 +3,9 @@ import sys from common import loadData +from common import saveFile + +txtFile = 'xxrs.txt' def formatMetadata(metadata: dict) -> str: @@ -13,19 +16,15 @@ def formatMetadata(metadata: dict) -> str: ) -def formatChapter(caption: str, content: list) -> str: - return '\n\n'.join([caption] + content) - - def txtRelease(metadata: dict, content: dict) -> str: result = [formatMetadata(metadata)] for (title, chapter) in content.items(): - result.append( - formatChapter(title, chapter) - ) - return '\n\n\n'.join(result) + result.append('\n\n'.join([title] + chapter)) + return '\n\n\n'.join(result) + '\n' if __name__ == '__main__': data = loadData(sys.argv[1]) - print(txtRelease(data['metadata'], data['content'])) + saveFile( + txtFile, txtRelease(data['metadata'], data['content']) + )