From a92cf75c1f1b6515995a33543177908d545d0c59 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sat, 18 Mar 2023 01:18:46 +0800 Subject: [PATCH] feat: calibre package release --- src/release/utils/common.py | 2 +- src/release/utils/release.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/release/utils/common.py b/src/release/utils/common.py index e016293..de801d9 100644 --- a/src/release/utils/common.py +++ b/src/release/utils/common.py @@ -19,9 +19,9 @@ releaseInfo = { # release file name 'txt': '栩栩若生.txt', 'epub': '栩栩若生.epub', 'mobi': '栩栩若生.mobi', + 'calibre': 'xxrs.zip', 'static': 'XXRS.tar.xz', 'gitbook': 'xxrs-online/', - 'calibre': 'xxrs-calibre/', } releaseInfo = { # convert to absolute path key: os.path.join(releasePath, file) for (key, file) in releaseInfo.items() diff --git a/src/release/utils/release.py b/src/release/utils/release.py index 5b27cd6..5361552 100644 --- a/src/release/utils/release.py +++ b/src/release/utils/release.py @@ -169,6 +169,14 @@ def calibreDepends(workDir: str, metadata: dict, content: dict) -> None: saveFile(os.path.join(workDir, 'META-INF', 'container.xml'), '\n'.join(metaInfo) + '\n') +def calibreRelease(metadata: dict, content: dict) -> None: + tempDir = tempfile.TemporaryDirectory() # access temporary directory + calibreDepends(tempDir.name, metadata, content) + os.chdir(tempDir.name) + os.system('zip -qr %s *' % releaseInfo['calibre']) + tempDir.cleanup() + + def mobiRelease(metadata: dict, content: dict) -> None: - createFolder(releaseInfo['calibre']) - calibreDepends(releaseInfo['calibre'], metadata, content) + calibreRelease(metadata, content) + # TODO: using calibre convert as MOBI format