Skip to content

Commit

Permalink
Get rid of guess_cover()
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
Tsukurururu authored and kovidgoyal committed Jul 4, 2022
1 parent 34bba13 commit 87d2167
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/calibre/ebooks/metadata/opf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,26 +1158,6 @@ def primary_writing_mode(self):
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():
Expand Down Expand Up @@ -1239,11 +1219,6 @@ def cover(self):
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):
Expand Down

0 comments on commit 87d2167

Please sign in to comment.