mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
GUI: Convert, check for NoSupportedInputFormats.
This commit is contained in:
parent
3c045737da
commit
eda53229a4
@ -11,11 +11,13 @@ from PyQt4.Qt import QDialog
|
|||||||
|
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from calibre.gui2.convert import load_specifics
|
from calibre.gui2.convert import load_specifics
|
||||||
|
from calibre.gui2.convert.single import NoSupportedInputFormats
|
||||||
from calibre.gui2.convert.single import Config as SingleConfig
|
from calibre.gui2.convert.single import Config as SingleConfig
|
||||||
|
|
||||||
def convert_single_ebook(parent, db, row_ids, auto_conversion=False):
|
def convert_single_ebook(parent, db, row_ids, auto_conversion=False):
|
||||||
changed = False
|
changed = False
|
||||||
jobs = []
|
jobs = []
|
||||||
|
bad = []
|
||||||
|
|
||||||
total = len(row_ids)
|
total = len(row_ids)
|
||||||
if total == 0:
|
if total == 0:
|
||||||
@ -25,6 +27,7 @@ def convert_single_ebook(parent, db, row_ids, auto_conversion=False):
|
|||||||
for i, row_id in enumerate(row_ids):
|
for i, row_id in enumerate(row_ids):
|
||||||
temp_files = []
|
temp_files = []
|
||||||
|
|
||||||
|
try:
|
||||||
d = SingleConfig(parent, db, row_id)
|
d = SingleConfig(parent, db, row_id)
|
||||||
|
|
||||||
if auto_conversion:
|
if auto_conversion:
|
||||||
@ -52,6 +55,17 @@ def convert_single_ebook(parent, db, row_ids, auto_conversion=False):
|
|||||||
jobs.append(('ebook-convert', args, desc, d.output_format.upper(), row_id, temp_files))
|
jobs.append(('ebook-convert', args, desc, d.output_format.upper(), row_id, temp_files))
|
||||||
|
|
||||||
changed = True
|
changed = True
|
||||||
|
except NoSupportedInputFormats:
|
||||||
|
bad.append(row_id)
|
||||||
|
|
||||||
|
if bad != []:
|
||||||
|
res = []
|
||||||
|
for id in bad:
|
||||||
|
title = db.title(id, True)
|
||||||
|
res.append('<li>%s</li>'%title)
|
||||||
|
|
||||||
|
msg = _('<p>Could not convert %d of %d books, because no suitable source format was found.<ul>%s</ul>')%(len(res), total, '\n'.join(res))
|
||||||
|
warning_dialog(parent, _('Could not convert some books'), msg).exec_()
|
||||||
|
|
||||||
return jobs, changed
|
return jobs, changed
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user