diff --git a/src/calibre/ebooks/conversion/plugins/chm_input.py b/src/calibre/ebooks/conversion/plugins/chm_input.py index a674735f1d..30cf984c77 100644 --- a/src/calibre/ebooks/conversion/plugins/chm_input.py +++ b/src/calibre/ebooks/conversion/plugins/chm_input.py @@ -152,27 +152,31 @@ class CHMInput(InputFormatPlugin): #print "=============================" log.debug('Found %d section nodes' % len(chapters)) htmlpath = os.path.splitext(hhcpath)[0] + ".html" - f = open(htmlpath, 'wb') - if chapters: - f.write('
\n') - path0 = chapters[0][1] - subpath = os.path.dirname(path0) + with open(htmlpath, 'wb') as f: + if chapters: + f.write('\n') + path0 = chapters[0][1] + subpath = os.path.dirname(path0) + base = os.path.dirname(f.name) - for chapter in chapters: - title = chapter[0] - rsrcname = os.path.basename(chapter[1]) - rsrcpath = os.path.join(subpath, rsrcname) - # title should already be url encoded - url = "