mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
A spot of minor refactoring
This commit is contained in:
parent
4f317375f4
commit
614e304029
@ -1152,6 +1152,15 @@ class OPF(object): # {{{
|
|||||||
if 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
|
return cpath
|
||||||
|
|
||||||
|
@property
|
||||||
|
def epub3_raster_cover(self):
|
||||||
|
for item in self.itermanifest():
|
||||||
|
props = set((item.get('properties') or '').lower().split())
|
||||||
|
if 'cover-image' in props:
|
||||||
|
mt = item.get('media-type', '')
|
||||||
|
if mt and 'xml' not in mt and 'html' not in mt:
|
||||||
|
return item.get('href', None)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def raster_cover(self):
|
def raster_cover(self):
|
||||||
covers = self.raster_cover_path(self.metadata)
|
covers = self.raster_cover_path(self.metadata)
|
||||||
@ -1168,12 +1177,7 @@ class OPF(object): # {{{
|
|||||||
if mt and 'xml' not in mt and 'html' not in mt:
|
if mt and 'xml' not in mt and 'html' not in mt:
|
||||||
return item.get('href', None)
|
return item.get('href', None)
|
||||||
elif self.package_version >= 3.0:
|
elif self.package_version >= 3.0:
|
||||||
for item in self.itermanifest():
|
return self.epub3_raster_cover
|
||||||
props = set((item.get('properties') or '').lower().split())
|
|
||||||
if 'cover-image' in props:
|
|
||||||
mt = item.get('media-type', '')
|
|
||||||
if mt and 'xml' not in mt and 'html' not in mt:
|
|
||||||
return item.get('href', None)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def guide_raster_cover(self):
|
def guide_raster_cover(self):
|
||||||
|
@ -116,7 +116,9 @@ def simple_text(f):
|
|||||||
return normalize_whitespace(f(*args, **kw))
|
return normalize_whitespace(f(*args, **kw))
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
def items_with_property(root, q, prefixes):
|
def items_with_property(root, q, prefixes=None):
|
||||||
|
if prefixes is None:
|
||||||
|
prefixes = read_prefixes(root)
|
||||||
q = expand_prefix(q, known_prefixes).lower()
|
q = expand_prefix(q, known_prefixes).lower()
|
||||||
for item in XPath("./opf:manifest/opf:item[@properties]")(root):
|
for item in XPath("./opf:manifest/opf:item[@properties]")(root):
|
||||||
for prop in (item.get('properties') or '').lower().split():
|
for prop in (item.get('properties') or '').lower().split():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user