rclepub: use elt ids instead of hrefs + debug traces
This commit is contained in:
parent
9f4fed8bb6
commit
d4edbbaedb
@ -25,7 +25,7 @@ class rclEPUB:
|
|||||||
self.em = em
|
self.em = em
|
||||||
self.em.setmimetype(rclepub_html_mtype)
|
self.em.setmimetype(rclepub_html_mtype)
|
||||||
|
|
||||||
def extractone(self, path):
|
def extractone(self, id):
|
||||||
"""Extract one path-named internal file from the EPUB file"""
|
"""Extract one path-named internal file from the EPUB file"""
|
||||||
|
|
||||||
#self.em.rclog("extractone: [%s]"%(path))
|
#self.em.rclog("extractone: [%s]"%(path))
|
||||||
@ -34,13 +34,17 @@ class rclEPUB:
|
|||||||
iseof = rclexecm.RclExecM.eofnext
|
iseof = rclexecm.RclExecM.eofnext
|
||||||
|
|
||||||
try:
|
try:
|
||||||
doc = self.book.read(path)
|
item = self.book.get_item(id)
|
||||||
|
if item is None:
|
||||||
|
raise Exception("Item not found for id %s" % (id,))
|
||||||
|
doc = self.book.read_item(item)
|
||||||
doc = re.sub('''</[hH][eE][aA][dD]''',
|
doc = re.sub('''</[hH][eE][aA][dD]''',
|
||||||
'''<meta name="rclaptg" content="epub"></head>''', doc)
|
'''<meta name="rclaptg" content="epub"></head>''', doc)
|
||||||
return (True, doc, path, iseof)
|
self.em.setmimetype(rclepub_html_mtype)
|
||||||
|
return (True, doc, id, iseof)
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
self.em.rclog("openfile: failed: [%s]" % err)
|
self.em.rclog("extractone: failed: [%s]" % err)
|
||||||
return (False, "", path, iseof)
|
return (False, "", id, iseof)
|
||||||
|
|
||||||
def openfile(self, params):
|
def openfile(self, params):
|
||||||
"""Open the EPUB file"""
|
"""Open the EPUB file"""
|
||||||
@ -49,12 +53,12 @@ class rclEPUB:
|
|||||||
try:
|
try:
|
||||||
self.book = epub.open(params["filename:"])
|
self.book = epub.open(params["filename:"])
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
self.em.rclog("openfile: failed: [%s]" % err)
|
self.em.rclog("openfile: epub.open failed: [%s]" % err)
|
||||||
return False
|
return False
|
||||||
for id, item in self.book.opf.manifest.iteritems():
|
for id, item in self.book.opf.manifest.iteritems():
|
||||||
# print item.__dict__
|
# print item.__dict__
|
||||||
if item.media_type == u'application/xhtml+xml':
|
if item.media_type == u'application/xhtml+xml':
|
||||||
self.contents.append(item.href)
|
self.contents.append(id)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -120,7 +120,7 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
|
|||||||
ibuf.c_str()));
|
ibuf.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOGDEB(("MHExecMultiple: got name [%s] len: %d\n", name.c_str(), len));
|
|
||||||
if (len / 1024 > m_maxmemberkb) {
|
if (len / 1024 > m_maxmemberkb) {
|
||||||
LOGERR(("MHExecMultiple: data len > maxmemberkb\n"));
|
LOGERR(("MHExecMultiple: data len > maxmemberkb\n"));
|
||||||
return false;
|
return false;
|
||||||
@ -143,6 +143,9 @@ bool MimeHandlerExecMultiple::readDataElement(string& name, string &data)
|
|||||||
len, datap->length()));
|
len, datap->length()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
LOGDEB1(("MHExecMe:rdDtElt got: name [%s] len %d value [%s]\n",
|
||||||
|
name.c_str(), len, datap->size() > 100 ?
|
||||||
|
(datap->substr(0, 100) + " ...").c_str() : datap->c_str()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user