From 5849b45d11203a8172ff6c24dca21a9f651bb54c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 31 Jan 2011 16:25:32 -0700 Subject: [PATCH] Fix #8688 (Calibre fails to convert some buggy chm ebooks which doesn't have .hhc file.) --- src/calibre/ebooks/chm/reader.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/calibre/ebooks/chm/reader.py b/src/calibre/ebooks/chm/reader.py index 025e252005..04ce6d5efe 100644 --- a/src/calibre/ebooks/chm/reader.py +++ b/src/calibre/ebooks/chm/reader.py @@ -139,6 +139,13 @@ class CHMReader(CHMFile): if self.hhc_path not in files and files: self.hhc_path = files[0] + if self.hhc_path == '.hhc' and self.hhc_path not in files: + from calibre import walk + for x in walk(output_dir): + if os.path.basename(x).lower() in ('index.htm', 'index.html'): + self.hhc_path = os.path.relpath(x, output_dir) + break + def _reformat(self, data, htmlpath): try: data = xml_to_unicode(data, strip_encoding_pats=True)[0]