Get rid of guess_cover()

It was returning a bool rather than a path before and no one seemed to
have noticed, so it cant be needed.

See #1678 (opf2.py's OPF.guess_cover doesn't return the path)
This commit is contained in:
Tsukurururu 2022-07-04 15:47:17 +01:00 committed by Kovid Goyal
parent 34bba138e0
commit 87d2167270
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1158,26 +1158,6 @@ class OPF: # {{{
for m in self.XPath('//*[local-name()="meta" and @name="primary-writing-mode" and @content]')(self.root):
return m.get('content')
def guess_cover(self):
'''
Try to guess a cover. Needed for some old/badly formed OPF files.
'''
if self.base_dir and os.path.exists(self.base_dir):
for item in self.identifier_path(self.metadata):
scheme = None
for key in item.attrib.keys():
if key.endswith('scheme'):
scheme = item.get(key)
break
if scheme is None:
continue
if item.text:
prefix = item.text.replace('-', '')
for suffix in ['.jpg', '.jpeg', '.gif', '.png', '.bmp']:
cpath = os.access(os.path.join(self.base_dir, prefix+suffix), os.R_OK)
if os.access(os.path.join(self.base_dir, prefix+suffix), os.R_OK):
return cpath
@property
def epub3_raster_cover(self):
for item in self.itermanifest():
@ -1239,11 +1219,6 @@ class OPF: # {{{
for item in self.guide:
if item.type and item.type.lower() == t:
return item.path
try:
if self.try_to_guess_cover:
return self.guess_cover()
except:
pass
@cover.setter
def cover(self, path):