mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
[Enhancement] Skip non-existing files to avoid error. This is for better error handling.
This commit is contained in:
parent
57cd538894
commit
f53a5d33ec
@ -74,17 +74,18 @@ class SNBInput(InputFormatPlugin):
|
|||||||
chapterSrc = ch.get('src')
|
chapterSrc = ch.get('src')
|
||||||
fname = 'ch_%d.htm' % i
|
fname = 'ch_%d.htm' % i
|
||||||
data = snbFile.GetFileStream('snbc/' + chapterSrc)
|
data = snbFile.GetFileStream('snbc/' + chapterSrc)
|
||||||
if data != None:
|
if data == None:
|
||||||
snbc = etree.fromstring(data)
|
continue
|
||||||
outputFile = open(os.path.join(tdir, fname), 'wb')
|
snbc = etree.fromstring(data)
|
||||||
lines = []
|
outputFile = open(os.path.join(tdir, fname), 'wb')
|
||||||
for line in snbc.find('.//body'):
|
lines = []
|
||||||
if line.tag == 'text':
|
for line in snbc.find('.//body'):
|
||||||
lines.append(u'<p>%s</p>' % html_encode(line.text))
|
if line.tag == 'text':
|
||||||
elif line.tag == 'img':
|
lines.append(u'<p>%s</p>' % html_encode(line.text))
|
||||||
lines.append(u'<p><img src="%s" /></p>' % html_encode(line.text))
|
elif line.tag == 'img':
|
||||||
outputFile.write((HTML_TEMPLATE % (chapterName, u'\n'.join(lines))).encode('utf-8', 'replace'))
|
lines.append(u'<p><img src="%s" /></p>' % html_encode(line.text))
|
||||||
outputFile.close()
|
outputFile.write((HTML_TEMPLATE % (chapterName, u'\n'.join(lines))).encode('utf-8', 'replace'))
|
||||||
|
outputFile.close()
|
||||||
oeb.toc.add(ch.text, fname)
|
oeb.toc.add(ch.text, fname)
|
||||||
id, href = oeb.manifest.generate(id='html',
|
id, href = oeb.manifest.generate(id='html',
|
||||||
href=ascii_filename(fname))
|
href=ascii_filename(fname))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user