kindle manager

This commit is contained in:
douboer
2024-04-03 15:08:22 +08:00
parent 6b3c0f3b6b
commit 6df3ce42a3
459 changed files with 164651 additions and 4690 deletions

38
mobiparse/tests/test_mobi.py Executable file
View File

@@ -0,0 +1,38 @@
import os
import shutil
from os.path import abspath, join, exists, dirname, splitext
import mobi
from mobi.extract import extract, extracttest, extract_ncx_test
from loguru import logger
logger.add("logfile.log")
TEST_DIR = dirname(abspath(__file__))
def test_extract():
for fname in os.listdir(TEST_DIR):
ext = splitext(fname)[-1].upper()
if ext in [".MOBI", ".PRC", ".AZW", ".AZW3", ".AZW4"]:
tempdir, filepath = extract(join(TEST_DIR, fname))
assert exists(tempdir)
assert exists(filepath)
shutil.rmtree(tempdir)
def test_extract_file_like():
#bn = 'youxi.mobi'
#bn = 'xiaodao.mobi'
bn = 'woshi.azw3'
with open(join(TEST_DIR, bn), "rb") as infile:
tempdir, filepath = extracttest(infile)
print('infile {} tempdir {}, filepath {}'.format(infile, tempdir, filepath ))
# infile <_io.BufferedReader name='/Users/mark/mobiparse/mobimaster/tests/youxi.mobi'>
# tempdir ./t/, filepath ./t/mobi8/8x2vf7yv.epub
assert exists(tempdir)
assert exists(filepath)
#shutil.rmtree(tempdir)
if __name__=='__main__':
test_extract_file_like()
#extract_ncx_test()