diff --git a/openpecha/serializers/epub.py b/openpecha/serializers/epub.py
index 0a9a75bb..2197fe1f 100644
--- a/openpecha/serializers/epub.py
+++ b/openpecha/serializers/epub.py
@@ -126,8 +126,9 @@ def serialize(self, output_path="./output/epub_output"):
pecha_id (string): Pecha id that needs to be exported in other format
"""
+ output_path = Path(output_path)
pecha_id = self.opf_path.name.split(".")[0]
- out_fn = f"{pecha_id}.html"
+ out_html_fn = f"{pecha_id}.html"
try:
pecha_title = self.meta["ebook_metadata"]["title"]
except KeyError:
@@ -143,7 +144,7 @@ def serialize(self, output_path="./output/epub_output"):
f"\n
\n\t{pecha_title}\n\n\n"
)
results += f"{result}\n"
- Path(out_fn).write_text(results)
+ Path(out_html_fn).write_text(results)
# Downloading css template file from ebook template repo and saving it
template = requests.get(
"https://raw.githubusercontent.com/OpenPecha/ebook-template/master/tsadra_template.css"
@@ -157,9 +158,12 @@ def serialize(self, output_path="./output/epub_output"):
font_size = 15
chapter_mark = "pagebreak"
cover_path = self.opf_path / f"asset/image/{cover_image}"
+ out_epub_fn = output_path / f"{pecha_id}.epub"
os.system(
- f'ebook-convert {out_fn} {output_path}/{pecha_id}.epub --extra-css=./template.css --chapter={chapter_Xpath} --chapter-mark="{chapter_mark}" --base-font-size={font_size} --embed-font-family="{font_family}" --cover={cover_path}'
+ f'ebook-convert {out_html_fn} {out_epub_fn} --extra-css=./template.css --chapter={chapter_Xpath} --chapter-mark="{chapter_mark}" --base-font-size={font_size} --embed-font-family="{font_family}" --cover={cover_path}'
)
# Removing html file and template file
- os.system(f"rm {out_fn}")
+ os.system(f"rm {out_html_fn}")
os.system("rm template.css")
+
+ return out_epub_fn
diff --git a/tests/test_serialize.py b/tests/test_serialize.py
index a773ade9..d8078e0a 100644
--- a/tests/test_serialize.py
+++ b/tests/test_serialize.py
@@ -27,4 +27,5 @@ def test_hfml_serializer():
def test_hfml_2_tsadra_serializer(opf_path):
serializer = EpubSerializer(opf_path)
serializer.apply_layers()
- serializer.serialize()
+ out_fn = serializer.serialize()
+ assert str(out_fn) == "output/epub_output/P000100.epub"