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) \
|
OptionRecommendation.HIGH) \
|
||||||
for n in parser.options_iter()
|
for n in parser.options_iter()
|
||||||
if n.dest]
|
if n.dest]
|
||||||
|
print recommendations
|
||||||
plumber.merge_ui_recommendations(recommendations)
|
plumber.merge_ui_recommendations(recommendations)
|
||||||
|
|
||||||
plumber.run()
|
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
|
Logic for setting up conversion jobs
|
||||||
'''
|
'''
|
||||||
import os
|
|
||||||
|
import cPickle, os
|
||||||
|
|
||||||
from PyQt4.Qt import QDialog
|
from PyQt4.Qt import QDialog
|
||||||
|
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
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 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 out_format=None):
|
def convert_single_ebook(parent, db, row_ids, auto_conversion=False, out_format=None):
|
||||||
changed = False
|
changed = False
|
||||||
jobs = []
|
jobs = []
|
||||||
bad = []
|
bad = []
|
||||||
@ -32,8 +34,6 @@ def convert_single_ebook(parent, db, row_ids, auto_conversion=False out_format=N
|
|||||||
|
|
||||||
if auto_conversion:
|
if auto_conversion:
|
||||||
result = QDialog.Accepted
|
result = QDialog.Accepted
|
||||||
if d.output_format != out_format:
|
|
||||||
raise Exception('Output format not supported.')
|
|
||||||
else:
|
else:
|
||||||
result = d.exec_()
|
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))
|
desc = _('Convert book %d of %d (%s)') % (i + 1, total, repr(mi.title))
|
||||||
|
|
||||||
opts = load_specifics(db, row_id)
|
recs = cPickle.loads(d.recommendations)
|
||||||
opts_string = ''
|
args = [in_file, out_file.name, recs]
|
||||||
for opt in opts.keys():
|
|
||||||
opts_string += ' --%s %s ' % (opt, opts[opt])
|
|
||||||
|
|
||||||
args = [['', in_file, out_file.name, opts_string]]
|
|
||||||
temp_files = [out_file]
|
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
|
changed = True
|
||||||
except NoSupportedInputFormats:
|
except NoSupportedInputFormats:
|
||||||
|
@ -38,50 +38,21 @@ DEBUG = False
|
|||||||
|
|
||||||
#: A mapping from job names to functions that perform the jobs
|
#: A mapping from job names to functions that perform the jobs
|
||||||
PARALLEL_FUNCS = {
|
PARALLEL_FUNCS = {
|
||||||
'any2lrf' :
|
|
||||||
('calibre.ebooks.lrf.any.convert_from', 'main', dict(gui_mode=True), None),
|
|
||||||
|
|
||||||
'lrfviewer' :
|
'lrfviewer' :
|
||||||
('calibre.gui2.lrf_renderer.main', 'main', {}, None),
|
('calibre.gui2.lrf_renderer.main', 'main', {}, None),
|
||||||
|
|
||||||
'ebook-viewer' :
|
'ebook-viewer' :
|
||||||
('calibre.gui2.viewer.main', 'main', {}, None),
|
('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' :
|
'render_pages' :
|
||||||
('calibre.ebooks.comic.input', 'render_pages', {}, 'notification'),
|
('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' :
|
'ebook-convert' :
|
||||||
('calibre.ebooks.conversion.cli', 'main', {}, None),
|
('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