Skip to content

Commit

Permalink
ebook_mobi.py: refactor, run kindlegen with relative file path, #613
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Dec 27, 2024
1 parent b52f9c8 commit 745e4c3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pyglossary/plugins/ebook_mobi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import os
from datetime import datetime
from os.path import join
from os.path import join, split
from typing import TYPE_CHECKING

from pyglossary.core import log
Expand Down Expand Up @@ -375,11 +375,18 @@ def write(self) -> Generator[None, EntryType, None]:
return

# name = self._glos.getInfo("name")

log.info(f"Creating .mobi file with kindlegen, using {kindlegen_path!r}")
opf_path_abs = join(filename, "OEBPS", "content.opf")
direc, filename = split(filename)
cmd = [
kindlegen_path,
join(filename, "OEBPS", "content.opf"),
"-gen_ff_mobi7",
"-o",
"content.mobi",
]
proc = subprocess.Popen(
[kindlegen_path, opf_path_abs, "-gen_ff_mobi7", "-o", "content.mobi"],
cmd,
cwd=direc,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.PIPE,
Expand Down

0 comments on commit 745e4c3

Please sign in to comment.