You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
743 B
31 lines
743 B
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import sys
|
|
from common import loadData
|
|
|
|
|
|
def formatMetadata(metadata: dict) -> str:
|
|
return '%s\n\n作者:%s\n\n\n%s' % (
|
|
metadata['name'],
|
|
metadata['author'],
|
|
'\n\n'.join(metadata['desc']),
|
|
)
|
|
|
|
|
|
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)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
data = loadData(sys.argv[1])
|
|
print(txtRelease(data['metadata'], data['content']))
|
|
|