added ui where you can suppress searching for the djvutxt utility

(if it is not available the pure python txt extractor is used as fallback
anyway)
This commit is contained in:
Anthon 2011-10-04 23:53:15 +02:00
parent bfade8c911
commit b8cff2585b
4 changed files with 62 additions and 5 deletions

View File

@ -18,18 +18,24 @@ class DJVUInput(InputFormatPlugin):
author = 'Anthon van der Neut' author = 'Anthon van der Neut'
description = 'Convert OCR-ed DJVU files (.djvu) to HTML' description = 'Convert OCR-ed DJVU files (.djvu) to HTML'
file_types = set(['djvu']) file_types = set(['djvu'])
output_encoding = None #output_encoding = None
recommendations = set( options = set([
# [('page_breaks_before', '/', OptionRecommendation.MED)] OptionRecommendation(name='use_djvutxt', recommended_value=True,
) help=_('try to use the djvutxt program and fall back to pure python implementation if it fails or is not available')),
])
#recommendations = set(
# [('try djvutxt', '/', OptionRecommendation.MED)]
#)
def convert(self, stream, options, file_ext, log, accelerators): def convert(self, stream, options, file_ext, log, accelerators):
stdout = StringIO() stdout = StringIO()
ppdjvu = True ppdjvu = True
log.debug('options: %d' % (options.use_djvutxt))
# using djvutxt is MUCH faster, should make it an option # using djvutxt is MUCH faster, should make it an option
if False and os.path.exists('/usr/bin/djvutxt'): if options.use_djvutxt and os.path.exists('/usr/bin/djvutxt'):
from calibre.ptempfile import PersistentTemporaryFile from calibre.ptempfile import PersistentTemporaryFile
try: try:
fp = PersistentTemporaryFile(suffix='.djvu', prefix='calibre') fp = PersistentTemporaryFile(suffix='.djvu', prefix='calibre')

View File

@ -56,6 +56,7 @@ class Widget(QWidget):
self._icon = QIcon(self.ICON) self._icon = QIcon(self.ICON)
for name in self._options: for name in self._options:
if not hasattr(self, 'opt_'+name): if not hasattr(self, 'opt_'+name):
print dir(self)
raise Exception('Option %s missing in %s'%(name, raise Exception('Option %s missing in %s'%(name,
self.__class__.__name__)) self.__class__.__name__))
self.connect_gui_obj(getattr(self, 'opt_'+name)) self.connect_gui_obj(getattr(self, 'opt_'+name))

View File

@ -0,0 +1,22 @@
# coding: utf-8
__license__ = 'GPL v3'
__copyright__ = '2011, Anthon van der Neut <A.van.der.Neut@ruamel.eu>'
from calibre.gui2.convert.djvu_input_ui import Ui_Form
from calibre.gui2.convert import Widget, QDoubleSpinBox
class PluginWidget(Widget, Ui_Form):
TITLE = _('DJVU Input')
HELP = _('Options specific to')+' DJVU '+_('input')
COMMIT_NAME = 'djvu_input'
ICON = I('mimetypes/djvu.png')
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
Widget.__init__(self, parent,
['use_djvutxt', ])
self.db, self.book_id = db, book_id
self.initialize_options(get_option, get_help, db, book_id)

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QCheckBox" name="opt_use_djvutxt">
<property name="text">
<string>Use &amp;djvutxt</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>