mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-22 15:46:10 +01:00
...
This commit is contained in:
parent
060097146d
commit
0fb35bb7d0
1 changed files with 13 additions and 1 deletions
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
from calibre import prepare_string_for_xml as xml
|
||||
from calibre.ebooks.oeb.polish.check.base import BaseError, WARN
|
||||
from calibre.ebooks.oeb.base import OPF, OPF2_NS
|
||||
|
||||
class MissingSection(BaseError):
|
||||
|
||||
|
|
@ -49,8 +50,14 @@ def __call__(self, container):
|
|||
def check_opf(container):
|
||||
errors = []
|
||||
|
||||
if container.opf.tag != OPF('package'):
|
||||
err = BaseError(_('The OPF does not have the correct root element'), container.opf_name)
|
||||
err.HELP = xml(_(
|
||||
'The opf must have the root element <package> in namespace {0}, like this: <package xmlns="{0}">')).format(OPF2_NS)
|
||||
errors.append(err)
|
||||
|
||||
for tag in ('metadata', 'manifest', 'spine'):
|
||||
if not container.opf_xpath('//opf:' + tag):
|
||||
if not container.opf_xpath('/opf:package/opf:' + tag):
|
||||
errors.append(MissingSection(container.opf_name, tag))
|
||||
|
||||
all_ids = set(container.opf_xpath('//*/@id'))
|
||||
|
|
@ -62,4 +69,9 @@ def check_opf(container):
|
|||
if nl_items:
|
||||
errors.append(NonLinearItems(container.opf_name, nl_items))
|
||||
|
||||
# Check unique identifier, version, <meta> tag with name before content for
|
||||
# cover and content pointing to proper manifest item. Duplicate items in
|
||||
# spine. Duplicate hrefs in manifest. hrefs in manifest that point to
|
||||
# missing resources.
|
||||
|
||||
return errors
|
||||
|
|
|
|||
Loading…
Reference in a new issue