Cleanup previous PR

This commit is contained in:
Kovid Goyal 2024-08-04 14:42:46 +05:30
parent 74d685ffa4
commit 0ce8e9af3c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -10,7 +10,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import io import io
import os import os
import posixpath import posixpath
from contextlib import closing from contextlib import closing, suppress
from calibre import CurrentDir from calibre import CurrentDir
from calibre.ebooks.metadata.opf import get_metadata as get_metadata_from_opf from calibre.ebooks.metadata.opf import get_metadata as get_metadata_from_opf
@ -22,6 +22,7 @@ from calibre.utils.localunzip import LocalZipFile
from calibre.utils.xml_parse import safe_xml_fromstring from calibre.utils.xml_parse import safe_xml_fromstring
from calibre.utils.zipfile import BadZipfile, ZipFile, safe_replace from calibre.utils.zipfile import BadZipfile, ZipFile, safe_replace
class EPubException(Exception): class EPubException(Exception):
pass pass
@ -133,7 +134,7 @@ class OCFReader(OCF):
def exists(self, path): def exists(self, path):
try: try:
self.open(path) self.open(path).close()
return True return True
except OSError: except OSError:
return False return False
@ -214,6 +215,7 @@ def render_cover(cpage, zf, reader=None):
if not os.path.exists(cpage): if not os.path.exists(cpage):
return return
with suppress(Exception):
# In the case of manga, the first spine item may be an image # In the case of manga, the first spine item may be an image
# already, so treat it as a raster cover. # already, so treat it as a raster cover.
file_format = what_image_type(cpage) file_format = what_image_type(cpage)