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')
|
||||
fname = 'ch_%d.htm' % i
|
||||
data = snbFile.GetFileStream('snbc/' + chapterSrc)
|
||||
if data != None:
|
||||
snbc = etree.fromstring(data)
|
||||
outputFile = open(os.path.join(tdir, fname), 'wb')
|
||||
lines = []
|
||||
for line in snbc.find('.//body'):
|
||||
if line.tag == 'text':
|
||||
lines.append(u'<p>%s</p>' % html_encode(line.text))
|
||||
elif line.tag == 'img':
|
||||
lines.append(u'<p><img src="%s" /></p>' % html_encode(line.text))
|
||||
outputFile.write((HTML_TEMPLATE % (chapterName, u'\n'.join(lines))).encode('utf-8', 'replace'))
|
||||
outputFile.close()
|
||||
if data == None:
|
||||
continue
|
||||
snbc = etree.fromstring(data)
|
||||
outputFile = open(os.path.join(tdir, fname), 'wb')
|
||||
lines = []
|
||||
for line in snbc.find('.//body'):
|
||||
if line.tag == 'text':
|
||||
lines.append(u'<p>%s</p>' % html_encode(line.text))
|
||||
elif line.tag == 'img':
|
||||
lines.append(u'<p><img src="%s" /></p>' % html_encode(line.text))
|
||||
outputFile.write((HTML_TEMPLATE % (chapterName, u'\n'.join(lines))).encode('utf-8', 'replace'))
|
||||
outputFile.close()
|
||||
oeb.toc.add(ch.text, fname)
|
||||
id, href = oeb.manifest.generate(id='html',
|
||||
href=ascii_filename(fname))
|
||||
|
Loading…
x
Reference in New Issue
Block a user