mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Sync to trunk.
This commit is contained in:
commit
05d27a0225
@ -2,7 +2,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
__appname__ = 'calibre'
|
||||
__version__ = '0.6.0b6'
|
||||
__version__ = '0.6.0b8'
|
||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
||||
|
||||
import re
|
||||
|
@ -35,12 +35,10 @@ class BEBOOK(USBMS):
|
||||
|
||||
SUPPORTS_SUB_DIRS = True
|
||||
|
||||
FDI_LUNS = {'lun0':1, 'lun1':0, 'lun2':2}
|
||||
|
||||
def windows_sort_drives(self, drives):
|
||||
main = drives.get('main', None)
|
||||
card = drives.get('carda', None)
|
||||
if card and main and card < main:
|
||||
if card and main and card > main:
|
||||
drives['main'] = card
|
||||
drives['carda'] = main
|
||||
|
||||
@ -63,7 +61,7 @@ class BEBOOK(USBMS):
|
||||
except:
|
||||
card_num = None
|
||||
|
||||
if card_num is not None and main_num is not None and card_num < main_num:
|
||||
if card_num is not None and main_num is not None and card_num > main_num:
|
||||
names['main'] = card
|
||||
names['carda'] = main
|
||||
|
||||
|
@ -217,7 +217,7 @@ class EPUBOutput(OutputFormatPlugin):
|
||||
Perform various markup transforms to get the output to render correctly
|
||||
in the quirky ADE.
|
||||
'''
|
||||
from calibre.ebooks.oeb.base import XPNSMAP, XHTML
|
||||
from calibre.ebooks.oeb.base import XPNSMAP, XHTML, OEB_STYLES
|
||||
from lxml.etree import XPath as _XPath
|
||||
from functools import partial
|
||||
XPath = partial(_XPath, namespaces=XPNSMAP)
|
||||
@ -276,12 +276,6 @@ class EPUBOutput(OutputFormatPlugin):
|
||||
for tag in XPath('//h:img[@src]')(root):
|
||||
tag.set('src', tag.get('src', '').replace('&', ''))
|
||||
|
||||
stylesheet = self.oeb.manifest.hrefs['stylesheet.css']
|
||||
stylesheet.data.add('a { color: inherit; text-decoration: inherit; '
|
||||
'cursor: default; }')
|
||||
stylesheet.data.add('a[href] { color: blue; '
|
||||
'text-decoration: underline; cursor:pointer; }')
|
||||
|
||||
special_chars = re.compile(u'[\u200b\u00ad]')
|
||||
for elem in root.iterdescendants():
|
||||
if getattr(elem, 'text', False):
|
||||
@ -291,5 +285,19 @@ class EPUBOutput(OutputFormatPlugin):
|
||||
elem.tail = special_chars.sub('', elem.tail)
|
||||
elem.tail = elem.tail.replace(u'\u2011', '-')
|
||||
|
||||
stylesheet = None
|
||||
for item in self.oeb.manifest:
|
||||
if item.media_type.lower() in OEB_STYLES:
|
||||
stylesheet = item
|
||||
break
|
||||
|
||||
if stylesheet is not None:
|
||||
stylesheet.data.add('a { color: inherit; text-decoration: inherit; '
|
||||
'cursor: default; }')
|
||||
stylesheet.data.add('a[href] { color: blue; '
|
||||
'text-decoration: underline; cursor:pointer; }')
|
||||
else:
|
||||
self.oeb.log.warn('No stylesheet found')
|
||||
|
||||
|
||||
|
||||
|
@ -228,7 +228,7 @@ class Config(ResizableDialog, Ui_Dialog):
|
||||
return
|
||||
x = w.commit(save_defaults=False)
|
||||
recs.update(x)
|
||||
self.opf_path, self.cover_path = self.mw.opf_file, self.mw.cover_file
|
||||
self.opf_file, self.cover_file = self.mw.opf_file, self.mw.cover_file
|
||||
self._recommendations = recs
|
||||
if self.db is not None:
|
||||
recs['gui_preferred_input_format'] = self.input_format
|
||||
|
@ -73,7 +73,8 @@ class JobManager(QAbstractTableModel):
|
||||
if col == 1:
|
||||
return QVariant(job.status_text)
|
||||
if col == 2:
|
||||
return QVariant(job.percent)
|
||||
p = 100. if job.is_finished else job.percent
|
||||
return QVariant(p)
|
||||
if col == 3:
|
||||
rtime = job.running_time
|
||||
if rtime is None:
|
||||
|
@ -48,12 +48,21 @@ def convert_single_ebook(parent, db, book_ids, auto_conversion=False, out_format
|
||||
out_file = PersistentTemporaryFile('.' + d.output_format)
|
||||
out_file.write(d.output_format)
|
||||
out_file.close()
|
||||
temp_files = []
|
||||
|
||||
desc = _('Convert book %d of %d (%s)') % (i + 1, total, repr(mi.title))
|
||||
|
||||
recs = cPickle.loads(d.recommendations)
|
||||
args = [in_file, out_file.name, recs]
|
||||
temp_files = [out_file]
|
||||
if d.opf_file is not None:
|
||||
recs.append(('read_metadata_from_opf', d.opf_file.name,
|
||||
OptionRecommendation.HIGH))
|
||||
temp_files.append(d.opf_file)
|
||||
if d.cover_file is not None:
|
||||
recs.append(('cover', d.cover_file.name,
|
||||
OptionRecommendation.HIGH))
|
||||
temp_files.append(d.cover_file)
|
||||
temp_files.append(out_file)
|
||||
jobs.append(('gui_convert', args, desc, d.output_format.upper(), book_id, temp_files))
|
||||
|
||||
changed = True
|
||||
@ -104,11 +113,23 @@ def convert_bulk_ebook(parent, db, book_ids, out_format=None):
|
||||
out_file = PersistentTemporaryFile('.' + output_format)
|
||||
out_file.write(output_format)
|
||||
out_file.close()
|
||||
temp_files = []
|
||||
|
||||
lrecs = list(recs)
|
||||
|
||||
if d.opf_file is not None:
|
||||
lrecs.append(('read_metadata_from_opf', d.opf_file.name,
|
||||
OptionRecommendation.HIGH))
|
||||
temp_files.append(d.opf_file)
|
||||
if d.cover_file is not None:
|
||||
lrecs.append(('cover', d.cover_file.name,
|
||||
OptionRecommendation.HIGH))
|
||||
temp_files.append(d.cover_file)
|
||||
|
||||
desc = _('Convert book %d of %d (%s)') % (i + 1, total, repr(mi.title))
|
||||
|
||||
args = [in_file, out_file.name, recs]
|
||||
temp_files = [out_file]
|
||||
args = [in_file, out_file.name, lrecs]
|
||||
temp_files.append(out_file)
|
||||
jobs.append(('gui_convert', args, desc, d.output_format.upper(), book_id, temp_files))
|
||||
|
||||
changed = True
|
||||
|
@ -190,6 +190,10 @@ class Document(QWebPage):
|
||||
def animated_scroll_done(self):
|
||||
self.emit(SIGNAL('animated_scroll_done()'))
|
||||
|
||||
@pyqtSignature("QString")
|
||||
def debug(self, msg):
|
||||
prints(msg)
|
||||
|
||||
def reference_mode(self, enable):
|
||||
self.javascript(('enter' if enable else 'leave')+'_reference_mode()')
|
||||
|
||||
|
@ -9,8 +9,8 @@ DEPENDENCIES = [
|
||||
('setuptools', '0.6c5', 'setuptools', 'python-setuptools', 'python-setuptools-devel'),
|
||||
('Python Imaging Library', '1.1.6', 'imaging', 'python-imaging', 'python-imaging'),
|
||||
('libusb', '0.1.12', None, None, None),
|
||||
('Qt', '4.5.0', 'qt', 'libqt4-core libqt4-gui', 'qt4'),
|
||||
('PyQt', '4.5.0', 'PyQt4', 'python-qt4', 'PyQt4'),
|
||||
('Qt', '4.5.1', 'qt', 'libqt4-core libqt4-gui', 'qt4'),
|
||||
('PyQt', '4.5.1', 'PyQt4', 'python-qt4', 'PyQt4'),
|
||||
('python-mechanize', '0.1.11', 'dev-python/mechanize', 'python-mechanize', 'python-mechanize'),
|
||||
('ImageMagick', '6.3.5', 'imagemagick', 'imagemagick', 'ImageMagick'),
|
||||
('xdg-utils', '1.0.2', 'xdg-utils', 'xdg-utils', 'xdg-utils'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user