Browse Source

update: txt release process

master
Dnomd343 2 years ago
parent
commit
5168b2ab37
  1. 17
      src/release/to_txt.py

17
src/release/to_txt.py

@ -3,6 +3,9 @@
import sys import sys
from common import loadData from common import loadData
from common import saveFile
txtFile = 'xxrs.txt'
def formatMetadata(metadata: dict) -> str: 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: def txtRelease(metadata: dict, content: dict) -> str:
result = [formatMetadata(metadata)] result = [formatMetadata(metadata)]
for (title, chapter) in content.items(): for (title, chapter) in content.items():
result.append( result.append('\n\n'.join([title] + chapter))
formatChapter(title, chapter) return '\n\n\n'.join(result) + '\n'
)
return '\n\n\n'.join(result)
if __name__ == '__main__': if __name__ == '__main__':
data = loadData(sys.argv[1]) data = loadData(sys.argv[1])
print(txtRelease(data['metadata'], data['content'])) saveFile(
txtFile, txtRelease(data['metadata'], data['content'])
)

Loading…
Cancel
Save