mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Sync to Trunk.
This commit is contained in:
commit
95ade95c60
@ -79,11 +79,11 @@ class KOBO(USBMS):
|
||||
|
||||
# Determine the firmware version
|
||||
f = open(self.normalize_path(self._main_prefix + '.kobo/version'), 'r')
|
||||
fwversion = f.readline().split(',')[2]
|
||||
self.fwversion = f.readline().split(',')[2]
|
||||
f.close()
|
||||
if fwversion != '1.0' and fwversion != '1.4':
|
||||
if self.fwversion != '1.0' and self.fwversion != '1.4':
|
||||
self.has_kepubs = True
|
||||
debug_print('Version of firmware: ', fwversion, 'Has kepubs:', self.has_kepubs)
|
||||
debug_print('Version of firmware: ', self.fwversion, 'Has kepubs:', self.has_kepubs)
|
||||
|
||||
self.booklist_class.rebuild_collections = self.rebuild_collections
|
||||
|
||||
@ -220,6 +220,7 @@ class KOBO(USBMS):
|
||||
# 2) volume_shorcover
|
||||
# 2) content
|
||||
|
||||
debug_print('delete_via_sql: ContentID: ', ContentID, 'ContentType: ', ContentType)
|
||||
connection = sqlite.connect(self.normalize_path(self._main_prefix + '.kobo/KoboReader.sqlite'))
|
||||
cursor = connection.cursor()
|
||||
t = (ContentID,)
|
||||
@ -400,6 +401,12 @@ class KOBO(USBMS):
|
||||
elif extension == '.pdf' or extension == '.epub':
|
||||
# print "ePub or pdf"
|
||||
ContentType = 16
|
||||
elif extension == '.rtf' or extension == '.txt' or extension == '.htm' or extension == '.html':
|
||||
# print "txt"
|
||||
if self.fwversion == '1.0' or self.fwversion == '1.4' or self.fwversion == '1.7.4':
|
||||
ContentType = 999
|
||||
else:
|
||||
ContentType = 901
|
||||
else: # if extension == '.html' or extension == '.txt':
|
||||
ContentType = 999 # Yet another hack: to get around Kobo changing how ContentID is stored
|
||||
return ContentType
|
||||
|
@ -240,18 +240,26 @@ class Stylizer(object):
|
||||
else:
|
||||
for elem in matches:
|
||||
self.style(elem)._update_cssdict(cssdict)
|
||||
for elem in xpath(tree, '//h:img[@width or @height]'):
|
||||
base = elem.get('style', '').strip()
|
||||
if base:
|
||||
base += ';'
|
||||
for prop in ('width', 'height'):
|
||||
val = elem.get(prop, False)
|
||||
if val:
|
||||
base += '%s: %s;'%(prop, val)
|
||||
del elem.attrib[prop]
|
||||
elem.set('style', base)
|
||||
for elem in xpath(tree, '//h:*[@style]'):
|
||||
self.style(elem)._apply_style_attr()
|
||||
num_pat = re.compile(r'\d+$')
|
||||
for elem in xpath(tree, '//h:img[@width or @height]'):
|
||||
style = self.style(elem)
|
||||
# Check if either height or width is not default
|
||||
is_styled = style._style.get('width', 'auto') != 'auto' or \
|
||||
style._style.get('height', 'auto') != 'auto'
|
||||
if not is_styled:
|
||||
# Update img style dimension using width and height
|
||||
upd = {}
|
||||
for prop in ('width', 'height'):
|
||||
val = elem.get(prop, '').strip()
|
||||
del elem.attrib[prop]
|
||||
if val:
|
||||
if num_pat.match(val) is not None:
|
||||
val += 'px'
|
||||
upd[prop] = val
|
||||
if upd:
|
||||
style._update_cssdict(upd)
|
||||
|
||||
def _fetch_css_file(self, path):
|
||||
hrefs = self.oeb.manifest.hrefs
|
||||
|
@ -18,6 +18,7 @@ from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
from calibre.constants import preferred_encoding, filesystem_encoding
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2 import config
|
||||
|
||||
class AddAction(InterfaceAction):
|
||||
|
||||
@ -101,7 +102,12 @@ class AddAction(InterfaceAction):
|
||||
else:
|
||||
ids.add(db.import_book(mi, []))
|
||||
self.gui.library_view.model().books_added(len(books))
|
||||
self.gui.iactions['Edit Metadata'].do_download_metadata(ids)
|
||||
orig = config['overwrite_author_title_metadata']
|
||||
config['overwrite_author_title_metadata'] = True
|
||||
try:
|
||||
self.gui.iactions['Edit Metadata'].do_download_metadata(ids)
|
||||
finally:
|
||||
config['overwrite_author_title_metadata'] = orig
|
||||
|
||||
|
||||
def files_dropped(self, paths):
|
||||
|
Loading…
x
Reference in New Issue
Block a user