aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xepy.py6
2 files changed, 6 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 9d23584..8a94ee5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ epy_reader.egg-info/*
.idea
build
dist
+tmp/
diff --git a/epy.py b/epy.py
index 5bf2915..0298b4f 100755
--- a/epy.py
+++ b/epy.py
@@ -644,7 +644,9 @@ class Mobi(Epub):
def get_img_bytestr(self, impath: str) -> Tuple[str, bytes]:
# TODO: test on windows
# if impath "Images/asdf.png" is problematic
- with open(os.path.join(self.root_dirpath, impath), "rb") as f:
+ image_abspath = os.path.join(self.root_dirpath, impath)
+ image_abspath = os.path.normpath(image_abspath) # handle crossplatform path
+ with open(image_abspath, "rb") as f:
src = f.read()
return impath, src
@@ -1714,6 +1716,8 @@ def resolve_path(current_dir: str, relative_path: str) -> str:
eg. '/foo/bar/book.html' + '../img.png' = '/foo/img.png'
NOTE: '/' suffix is important to tell that current dir in 'bar'
"""
+ # can also using os.path.normpath()
+ # but if the image in zipfile then posix path is mandatory
return urljoin(current_dir, relative_path)