Browse Source

feat: calibre package release

master
Dnomd343 2 years ago
parent
commit
a92cf75c1f
  1. 2
      src/release/utils/common.py
  2. 12
      src/release/utils/release.py

2
src/release/utils/common.py

@ -19,9 +19,9 @@ releaseInfo = { # release file name
'txt': '栩栩若生.txt', 'txt': '栩栩若生.txt',
'epub': '栩栩若生.epub', 'epub': '栩栩若生.epub',
'mobi': '栩栩若生.mobi', 'mobi': '栩栩若生.mobi',
'calibre': 'xxrs.zip',
'static': 'XXRS.tar.xz', 'static': 'XXRS.tar.xz',
'gitbook': 'xxrs-online/', 'gitbook': 'xxrs-online/',
'calibre': 'xxrs-calibre/',
} }
releaseInfo = { # convert to absolute path releaseInfo = { # convert to absolute path
key: os.path.join(releasePath, file) for (key, file) in releaseInfo.items() key: os.path.join(releasePath, file) for (key, file) in releaseInfo.items()

12
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') 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: def mobiRelease(metadata: dict, content: dict) -> None:
createFolder(releaseInfo['calibre']) calibreRelease(metadata, content)
calibreDepends(releaseInfo['calibre'], metadata, content) # TODO: using calibre convert as MOBI format

Loading…
Cancel
Save