diff --git a/src/calibre/gui2/convert/single.py b/src/calibre/gui2/convert/single.py index 332dc4ae92..cff7ee8c3d 100644 --- a/src/calibre/gui2/convert/single.py +++ b/src/calibre/gui2/convert/single.py @@ -33,7 +33,10 @@ from calibre.utils.config import prefs from calibre.utils.logging import Log class NoSupportedInputFormats(Exception): - pass + + def __init__(self, available_formats): + Exception.__init__(self) + self.available_formats = available_formats def sort_formats_by_preference(formats, prefs): uprefs = [x.upper() for x in prefs] @@ -86,7 +89,7 @@ def get_supported_input_formats_for_book(db, book_id): input_formats = set([x.lower() for x in supported_input_formats()]) input_formats = sorted(available_formats.intersection(input_formats)) if not input_formats: - raise NoSupportedInputFormats + raise NoSupportedInputFormats(tuple(x for x in available_formats if x)) return input_formats diff --git a/src/calibre/gui2/tools.py b/src/calibre/gui2/tools.py index f4ee92b565..98a59ccdd5 100644 --- a/src/calibre/gui2/tools.py +++ b/src/calibre/gui2/tools.py @@ -88,20 +88,35 @@ def convert_single_ebook(parent, db, book_ids, auto_conversion=False, # {{{ changed = True d.break_cycles() - except NoSupportedInputFormats: - bad.append(book_id) + except NoSupportedInputFormats as nsif: + bad.append((book_id, nsif.available_formats)) if bad and show_no_format_warning: - res = [] - for id in bad: - title = db.title(id, True) - res.append('%s'%title) + if len(bad) == 1 and not bad[0][1]: + title = db.title(bad[0][0], True) + warning_dialog(parent, _('Could not convert'), '

'+ + _('Could not convert %s as it has no ebook files. If you ' + 'think it should have files, but calibre is not finding ' + 'them, that is most likely because you moved the book\'s ' + 'files around outside of calibre. You will need to find those files ' + 'and re-add them to calibre.')%title, show=True) + else: + res = [] + for id, available_formats in bad: + title = db.title(id, True) + if available_formats: + msg = _('No supported formats (Available formats: %s)')%( + ', '.join(available_formats)) + else: + msg = _('This book has no actual ebook files') + res.append('%s - %s'%(title, msg)) - msg = '%s' % '\n'.join(res) - warning_dialog(parent, _('Could not convert some books'), - _('Could not convert %(num)d of %(tot)d books, because no suitable source' - ' format was found.') % dict(num=len(res), tot=total), - msg).exec_() + + msg = '%s' % '\n'.join(res) + warning_dialog(parent, _('Could not convert some books'), + _('Could not convert %(num)d of %(tot)d books, because no supported source' + ' formats were found.') % dict(num=len(res), tot=total), + msg).exec_() return jobs, changed, bad # }}}