mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Sync to trunk.
This commit is contained in:
commit
488d04cc08
@ -2,7 +2,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
__appname__ = 'calibre'
|
||||
__version__ = '0.6.0b10'
|
||||
__version__ = '0.6.0b11'
|
||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
||||
|
||||
import re
|
||||
|
@ -24,21 +24,26 @@ def read_metadata_(task, tdir, notification=lambda x,y:x):
|
||||
from calibre.ebooks.metadata.meta import metadata_from_formats
|
||||
from calibre.ebooks.metadata.opf2 import OPFCreator
|
||||
for x in task:
|
||||
id, formats = x
|
||||
if isinstance(formats, basestring): formats = [formats]
|
||||
mi = metadata_from_formats(formats)
|
||||
mi.cover = None
|
||||
cdata = None
|
||||
if mi.cover_data:
|
||||
cdata = mi.cover_data[-1]
|
||||
mi.cover_data = None
|
||||
opf = OPFCreator(tdir, mi)
|
||||
with open(os.path.join(tdir, '%s.opf'%id), 'wb') as f:
|
||||
opf.render(f)
|
||||
if cdata:
|
||||
with open(os.path.join(tdir, str(id)), 'wb') as f:
|
||||
f.write(cdata)
|
||||
notification(0.5, id)
|
||||
try:
|
||||
id, formats = x
|
||||
if isinstance(formats, basestring): formats = [formats]
|
||||
mi = metadata_from_formats(formats)
|
||||
mi.cover = None
|
||||
cdata = None
|
||||
if mi.cover_data:
|
||||
cdata = mi.cover_data[-1]
|
||||
mi.cover_data = None
|
||||
opf = OPFCreator(tdir, mi)
|
||||
with open(os.path.join(tdir, '%s.opf'%id), 'wb') as f:
|
||||
opf.render(f)
|
||||
if cdata:
|
||||
with open(os.path.join(tdir, str(id)), 'wb') as f:
|
||||
f.write(cdata)
|
||||
notification(0.5, id)
|
||||
except:
|
||||
import traceback
|
||||
with open(os.path.join(tdir, '%s.error'%id), 'wb') as f:
|
||||
f.write(traceback.format_exc())
|
||||
|
||||
class Progress(object):
|
||||
|
||||
@ -49,7 +54,10 @@ class Progress(object):
|
||||
def __call__(self, id):
|
||||
cover = os.path.join(self.tdir, str(id))
|
||||
if not os.path.exists(cover): cover = None
|
||||
self.result_queue.put((id, os.path.join(self.tdir, '%s.opf'%id), cover))
|
||||
res = os.path.join(self.tdir, '%s.error'%id)
|
||||
if not os.path.exists(res):
|
||||
res = res.replace('.error', '.opf')
|
||||
self.result_queue.put((id, res, cover))
|
||||
|
||||
class ReadMetadata(Thread):
|
||||
|
||||
|
@ -35,7 +35,7 @@ class Clean(object):
|
||||
for x in list(self.oeb.guide):
|
||||
href = urldefrag(self.oeb.guide[x].href)[0]
|
||||
if x.lower() not in ('cover', 'titlepage', 'masthead', 'toc',
|
||||
'title-page', 'copyright-page'):
|
||||
'title-page', 'copyright-page', 'start'):
|
||||
self.oeb.guide.remove(x)
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@ def _config():
|
||||
c.add_opt('asked_library_thing_password', default=False,
|
||||
help='Asked library thing password at least once.')
|
||||
c.add_opt('search_as_you_type', default=True,
|
||||
help='Start searching as you type. If this is disabled then seaerch will '
|
||||
help='Start searching as you type. If this is disabled then search will '
|
||||
'only take place when the Enter or Return key is pressed.')
|
||||
return ConfigProxy(c)
|
||||
|
||||
|
@ -44,6 +44,7 @@ class Adder(QObject):
|
||||
self.pd = ProgressDialog(_('Adding...'), parent=parent)
|
||||
self.spare_server = spare_server
|
||||
self.db = db
|
||||
self.critical = {}
|
||||
self.pd.setModal(True)
|
||||
self.pd.show()
|
||||
self._parent = parent
|
||||
@ -123,8 +124,12 @@ class Adder(QObject):
|
||||
return
|
||||
self.pd.value += 1
|
||||
formats = self.ids.pop(id)
|
||||
mi = MetaInformation(OPF(opf))
|
||||
name = self.nmap.pop(id)
|
||||
if opf.endswith('.error'):
|
||||
mi = MetaInformation('', [_('Unknown')])
|
||||
self.critical[name] = open(opf, 'rb').read().decode('utf-8', 'replace')
|
||||
else:
|
||||
mi = MetaInformation(OPF(opf))
|
||||
if not mi.title:
|
||||
mi.title = os.path.splitext(name)[0]
|
||||
mi.title = mi.title if isinstance(mi.title, unicode) else \
|
||||
|
@ -8,11 +8,9 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
|
||||
from PyQt4.Qt import SIGNAL
|
||||
|
||||
from calibre.gui2.convert.structure_detection_ui import Ui_Form
|
||||
from calibre.gui2.convert import Widget
|
||||
from calibre.gui2 import error_dialog, qstring_to_unicode
|
||||
from calibre.gui2 import error_dialog
|
||||
|
||||
class StructureDetectionWidget(Widget, Ui_Form):
|
||||
|
||||
@ -39,7 +37,7 @@ class StructureDetectionWidget(Widget, Ui_Form):
|
||||
for x in ('header_regex', 'footer_regex'):
|
||||
x = getattr(self, 'opt_'+x)
|
||||
try:
|
||||
pat = qstring_to_unicode(x.text())
|
||||
pat = unicode(x.text())
|
||||
re.compile(pat)
|
||||
except Exception, err:
|
||||
error_dialog(self, _('Invalid regular expression'),
|
||||
|
@ -13,7 +13,7 @@ import traceback
|
||||
from datetime import datetime
|
||||
|
||||
from PyQt4.QtCore import SIGNAL, QObject, QCoreApplication, Qt, QTimer, QThread, QDate
|
||||
from PyQt4.QtGui import QPixmap, QListWidgetItem, QErrorMessage, QDialog, QCompleter
|
||||
from PyQt4.QtGui import QPixmap, QListWidgetItem, QErrorMessage, QDialog
|
||||
|
||||
from calibre.gui2 import qstring_to_unicode, error_dialog, file_icon_provider, \
|
||||
choose_files, pixmap_to_data, choose_images, ResizableDialog
|
||||
|
@ -313,12 +313,14 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
cm.addAction(_('Convert individually'))
|
||||
cm.addAction(_('Bulk convert'))
|
||||
self.action_convert.setMenu(cm)
|
||||
self._convert_single_hook = partial(self.convert_ebook, bulk=False)
|
||||
QObject.connect(cm.actions()[0],
|
||||
SIGNAL('triggered(bool)'), partial(self.convert_ebook, bulk=False))
|
||||
SIGNAL('triggered(bool)'), self._convert_single_hook)
|
||||
self._convert_bulk_hook = partial(self.convert_ebook, bulk=True)
|
||||
QObject.connect(cm.actions()[1],
|
||||
SIGNAL('triggered(bool)'), partial(self.convert_ebook, bulk=True))
|
||||
SIGNAL('triggered(bool)'), self._convert_bulk_hook)
|
||||
QObject.connect(self.action_convert,
|
||||
SIGNAL('triggered(bool)'), partial(self.convert_ebook))
|
||||
SIGNAL('triggered(bool)'), self.convert_ebook)
|
||||
self.convert_menu = cm
|
||||
|
||||
pm = QMenu()
|
||||
@ -859,6 +861,13 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
self.library_view.model().books_added(self._adder.number_of_books_added)
|
||||
if hasattr(self, 'db_images'):
|
||||
self.db_images.reset()
|
||||
if self._adder.critical:
|
||||
det_msg = []
|
||||
for name, log in self._adder.critical.items():
|
||||
det_msg.append(name+'\n'+log)
|
||||
warning_dialog(self, _('Failed to read metadata'),
|
||||
_('Failed to read metadata from the following')+':',
|
||||
det_msg='\n\n'.join(det_msg), show=True)
|
||||
|
||||
self._adder = None
|
||||
|
||||
@ -1363,13 +1372,11 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
|
||||
if len(rows) >= 3:
|
||||
if not question_dialog(self, _('Multiple Books Selected'),
|
||||
_('You are attempting to open %i books. Opening to many '
|
||||
'books at once can be slow and have an negative effect on the '
|
||||
'responsiveness of your computer. Once started the process '
|
||||
'cannot be stopped until complete. Do you wish to continue?'
|
||||
% len(rows))):
|
||||
_('You are attempting to open %d books. Opening too many '
|
||||
'books at once can be slow and have a negative effect on the '
|
||||
)% len(rows)):
|
||||
return
|
||||
|
||||
|
||||
if self.current_view() is self.library_view:
|
||||
for row in rows:
|
||||
row = row.row()
|
||||
|
@ -92,6 +92,12 @@ class CybookG3(Device):
|
||||
manufacturer = 'Booken'
|
||||
id = 'cybookg3'
|
||||
|
||||
class CybookOpus(CybookG3):
|
||||
|
||||
name = 'Cybook Opus'
|
||||
output_format = 'EPUB'
|
||||
id = 'cybook_opus'
|
||||
|
||||
class BeBook(Device):
|
||||
|
||||
name = 'BeBook or BeBook Mini'
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -548,8 +548,10 @@ def _prefs():
|
||||
help=_('The language in which to display the user interface'))
|
||||
c.add_opt('output_format', default='EPUB',
|
||||
help=_('The default output format for ebook conversions.'))
|
||||
c.add_opt('input_format_order', default=['EPUB', 'MOBI', 'PRC', 'LIT'],
|
||||
help=_('Order list of formats to prefer for input.'))
|
||||
c.add_opt('input_format_order', default=['EPUB', 'MOBI', 'LIT', 'PRC',
|
||||
'FB2', 'HTML', 'HTM', 'XHTM', 'SHTML', 'XHTML', 'ODT', 'RTF', 'PDF',
|
||||
'TXT'],
|
||||
help=_('Ordered list of formats to prefer for input.'))
|
||||
c.add_opt('read_file_metadata', default=True,
|
||||
help=_('Read metadata from files'))
|
||||
c.add_opt('worker_process_priority', default='normal',
|
||||
|
Loading…
x
Reference in New Issue
Block a user