mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Beginnings of gui_conversion module.
This commit is contained in:
parent
dbe4123bc2
commit
6368f86626
@ -211,6 +211,7 @@ def main(args=sys.argv):
|
||||
OptionRecommendation.HIGH) \
|
||||
for n in parser.options_iter()
|
||||
if n.dest]
|
||||
print recommendations
|
||||
plumber.merge_ui_recommendations(recommendations)
|
||||
|
||||
plumber.run()
|
||||
|
17
src/calibre/gui2/convert/gui_conversion.py
Normal file
17
src/calibre/gui2/convert/gui_conversion.py
Normal file
@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
__license__ = 'GPL 3'
|
||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import logging
|
||||
|
||||
from calibre.ebooks.conversion.plumber import Plumber
|
||||
from calibre.utils.logging import Log
|
||||
|
||||
def gui_convert(input, output, recommendations):
|
||||
plumber = Plumber(input, output, Log())
|
||||
plumber.merge_ui_recommendations(recommendations)
|
||||
|
||||
plumber.run()
|
||||
|
@ -6,7 +6,9 @@ __docformat__ = 'restructuredtext en'
|
||||
'''
|
||||
Logic for setting up conversion jobs
|
||||
'''
|
||||
import os
|
||||
|
||||
import cPickle, os
|
||||
|
||||
from PyQt4.Qt import QDialog
|
||||
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
@ -14,7 +16,7 @@ from calibre.gui2.convert import load_specifics
|
||||
from calibre.gui2.convert.single import NoSupportedInputFormats
|
||||
from calibre.gui2.convert.single import Config as SingleConfig
|
||||
|
||||
def convert_single_ebook(parent, db, row_ids, auto_conversion=False out_format=None):
|
||||
def convert_single_ebook(parent, db, row_ids, auto_conversion=False, out_format=None):
|
||||
changed = False
|
||||
jobs = []
|
||||
bad = []
|
||||
@ -32,8 +34,6 @@ def convert_single_ebook(parent, db, row_ids, auto_conversion=False out_format=N
|
||||
|
||||
if auto_conversion:
|
||||
result = QDialog.Accepted
|
||||
if d.output_format != out_format:
|
||||
raise Exception('Output format not supported.')
|
||||
else:
|
||||
result = d.exec_()
|
||||
|
||||
@ -47,14 +47,10 @@ def convert_single_ebook(parent, db, row_ids, auto_conversion=False out_format=N
|
||||
|
||||
desc = _('Convert book %d of %d (%s)') % (i + 1, total, repr(mi.title))
|
||||
|
||||
opts = load_specifics(db, row_id)
|
||||
opts_string = ''
|
||||
for opt in opts.keys():
|
||||
opts_string += ' --%s %s ' % (opt, opts[opt])
|
||||
|
||||
args = [['', in_file, out_file.name, opts_string]]
|
||||
recs = cPickle.loads(d.recommendations)
|
||||
args = [in_file, out_file.name, recs]
|
||||
temp_files = [out_file]
|
||||
jobs.append(('ebook-convert', args, desc, d.output_format.upper(), row_id, temp_files))
|
||||
jobs.append(('gui_convert', args, desc, d.output_format.upper(), row_id, temp_files))
|
||||
|
||||
changed = True
|
||||
except NoSupportedInputFormats:
|
||||
|
@ -38,50 +38,21 @@ DEBUG = False
|
||||
|
||||
#: A mapping from job names to functions that perform the jobs
|
||||
PARALLEL_FUNCS = {
|
||||
'any2lrf' :
|
||||
('calibre.ebooks.lrf.any.convert_from', 'main', dict(gui_mode=True), None),
|
||||
|
||||
'lrfviewer' :
|
||||
('calibre.gui2.lrf_renderer.main', 'main', {}, None),
|
||||
|
||||
'ebook-viewer' :
|
||||
('calibre.gui2.viewer.main', 'main', {}, None),
|
||||
|
||||
'feeds2lrf' :
|
||||
('calibre.ebooks.lrf.feeds.convert_from', 'main', {}, 'notification'),
|
||||
|
||||
'render_table' :
|
||||
('calibre.ebooks.lrf.html.table_as_image', 'do_render', {}, None),
|
||||
|
||||
'render_pages' :
|
||||
('calibre.ebooks.comic.input', 'render_pages', {}, 'notification'),
|
||||
|
||||
'comic2lrf' :
|
||||
('calibre.ebooks.lrf.comic.convert_from', 'do_convert', {}, 'notification'),
|
||||
|
||||
'any2epub' :
|
||||
('calibre.ebooks.epub.from_any', 'any2epub', {}, None),
|
||||
|
||||
'feeds2epub' :
|
||||
('calibre.ebooks.epub.from_feeds', 'main', {}, 'notification'),
|
||||
|
||||
'comic2epub' :
|
||||
('calibre.ebooks.epub.from_comic', 'convert', {}, 'notification'),
|
||||
|
||||
'any2mobi' :
|
||||
('calibre.ebooks.mobi.from_any', 'any2mobi', {}, None),
|
||||
|
||||
'any2pdf' :
|
||||
('calibre.ebooks.pdf.from_any', 'any2pdf', {}, None),
|
||||
|
||||
'feeds2mobi' :
|
||||
('calibre.ebooks.mobi.from_feeds', 'main', {}, 'notification'),
|
||||
|
||||
'comic2mobi' :
|
||||
('calibre.ebooks.mobi.from_comic', 'convert', {}, 'notification'),
|
||||
|
||||
'ebook-convert' :
|
||||
('calibre.ebooks.conversion.cli', 'main', {}, None),
|
||||
|
||||
|
||||
'gui_convert' :
|
||||
('calibre.gui2.convert.gui_conversion', 'gui_convert', {}, None),
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user