Sync to trunk.

This commit is contained in:
John Schember 2009-06-12 06:14:40 -04:00
commit f7b9bc3b63
11 changed files with 115 additions and 87 deletions

View File

@ -2,7 +2,7 @@ __license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
__docformat__ = 'restructuredtext en'
__appname__ = 'calibre'
__version__ = '0.6.0b5'
__version__ = '0.6.0b6'
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
import re

View File

@ -350,8 +350,7 @@ from calibre.devices.blackberry.driver import BLACKBERRY
from calibre.devices.cybookg3.driver import CYBOOKG3
from calibre.devices.eb600.driver import EB600
from calibre.devices.jetbook.driver import JETBOOK
from calibre.devices.kindle.driver import KINDLE
from calibre.devices.kindle.driver import KINDLE2
from calibre.devices.kindle.driver import KINDLE, KINDLE2, KINDLE_DX
from calibre.devices.prs500.driver import PRS500
from calibre.devices.prs505.driver import PRS505
from calibre.devices.prs700.driver import PRS700
@ -397,6 +396,7 @@ plugins += [
JETBOOK,
KINDLE,
KINDLE2,
KINDLE_DX,
PRS500,
PRS505,
PRS700,

View File

@ -72,3 +72,16 @@ class KINDLE2(KINDLE):
PRODUCT_ID = [0x0002]
BCD = [0x0100]
class KINDLE_DX(KINDLE):
name = 'Kindle DX Device Interface'
description = _('Communicate with the Kindle 2 eBook reader.')
author = _('John Schember')
supported_platforms = ['windows', 'osx', 'linux']
FORMATS = ['azw', 'mobi', 'prc', 'azw1', 'tpz', 'pdf', 'txt']
PRODUCT_ID = [0x0003]
BCD = [0x0100]

View File

@ -233,7 +233,7 @@ class HTMLInput(InputFormatPlugin):
name = 'HTML Input'
author = 'Kovid Goyal'
description = 'Convert HTML and OPF files to an OEB'
file_types = set(['opf', 'html', 'htm', 'xhtml', 'xhtm'])
file_types = set(['opf', 'html', 'htm', 'xhtml', 'xhtm', 'shtm', 'shtml'])
options = set([
OptionRecommendation(name='breadth_first',

View File

@ -54,6 +54,7 @@ class LRFOptions(object):
self.minimize_memory_usage = False
self.autorotation = opts.enable_autorotation
self.header_separation = (self.profile.dpi/72.) * opts.header_separation
self.headerformat = opts.header_format
for x in ('top', 'bottom', 'left', 'right'):

View File

@ -300,9 +300,9 @@ class MobiReader(object):
root = html.fromstring(self.processed_html)
if root.xpath('descendant::p/descendant::p'):
from lxml.html import soupparser
self.log.warning('Markup contains unclosed <p> tags, parsing using',
'BeatifulSoup')
self.log.warning('Malformed markup, parsing using BeatifulSoup')
root = soupparser.fromstring(self.processed_html)
if root.tag != 'html':
self.log.warn('File does not have opening <html> tag')
nroot = html.fromstring('<html><head></head><body></body></html>')
@ -313,19 +313,26 @@ class MobiReader(object):
root = nroot
htmls = list(root.xpath('//html'))
if len(htmls) > 1:
self.log.warn('Markup contains multiple <html> tags')
# Keep only the largest head and body
self.log.warn('Markup contains multiple <html> tags, merging.')
# Merge all <head> and <body> sections
for h in htmls:
p = h.getparent()
if hasattr(p, 'remove'):
p.remove(h)
bodies, heads = root.xpath('//body'), root.xpath('//head')
def sz(x): return len(list(x.iter()))
def scmp(x, y): return cmp(sz(x), sz(y))
body = list(sorted(bodies, cmp=scmp))
head = list(sorted(heads, cmp=scmp))
for x in root: root.remove(x)
if head:
root.append(head[-1])
if body:
root.append(body[-1])
head, body = map(root.makeelement, ('head', 'body'))
for h in heads:
for x in h:
h.remove(x)
head.append(x)
for b in bodies:
for x in b:
b.remove(x)
body.append(x)
root.append(head), root.append(body)
for x in root.xpath('//script'):
x.getparent().remove(x)
@ -428,6 +435,7 @@ class MobiReader(object):
self.processed_html = '<html><p>' + self.processed_html.replace('\n\n', '<p>') + '</html>'
self.processed_html = self.processed_html.replace('\r\n', '\n')
self.processed_html = self.processed_html.replace('> <', '>\n<')
self.processed_html = re.sub('\x14|\x15', '', self.processed_html)
def upshift_markup(self, root):
self.log.debug('Converting style information to CSS...')

View File

@ -823,6 +823,7 @@ class Manifest(object):
for key in list(body.attrib.keys()):
if key == 'lang' or key.endswith('}lang'):
body.attrib.pop(key)
return data
def _parse_css(self, data):

View File

@ -17,7 +17,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Newline Type:</string>
<string>Line ending style:</string>
</property>
</widget>
</item>

View File

@ -1,4 +1,4 @@
from __future__ import with_statement
from __future__ import with_statement
__license__ = 'GPL v3'
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
@ -14,29 +14,29 @@ from calibre.gui2 import NONE, qstring_to_unicode
class BookmarkManager(QDialog, Ui_BookmarkManager):
def __init__(self, parent, bookmarks):
QDialog.__init__(self, parent)
self.setupUi(self)
self.bookmarks = bookmarks[:]
self.set_bookmarks()
self.connect(self.button_revert, SIGNAL('clicked()'), self.set_bookmarks)
self.connect(self.button_delete, SIGNAL('clicked()'), self.delete_bookmark)
self.connect(self.button_edit, SIGNAL('clicked()'), self.edit_bookmark)
self.connect(self.button_export, SIGNAL('clicked()'), self.export_bookmarks)
self.connect(self.button_import, SIGNAL('clicked()'), self.import_bookmarks)
def set_bookmarks(self, bookmarks=None):
if bookmarks == None:
bookmarks = self.bookmarks[:]
self._model = BookmarkTableModel(self, bookmarks)
self.bookmarks_table.setModel(self._model)
def delete_bookmark(self):
indexes = self.bookmarks_table.selectionModel().selectedIndexes()
if indexes != []:
self._model.remove_row(indexes[0].row())
def edit_bookmark(self):
indexes = self.bookmarks_table.selectionModel().selectedIndexes()
if indexes != []:
@ -44,27 +44,29 @@ class BookmarkManager(QDialog, Ui_BookmarkManager):
title = QVariant(unicode(title).strip())
if ok and title:
self._model.setData(indexes[0], title, Qt.EditRole)
def get_bookmarks(self):
return self._model.bookmarks
def export_bookmarks(self):
filename = QFileDialog.getSaveFileName(self, _("Export Bookmarks"), '%s%suntitled.pickle' % (os.getcwdu(), os.sep), _("Pickled Bookmarks (*.pickle)"))
filename = QFileDialog.getSaveFileName(self, _("Export Bookmarks"),
'%s%suntitled.pickle' % (os.getcwdu(), os.sep),
_("Saved Bookmarks (*.pickle)"))
if filename == '':
return
with open(filename, 'w') as fileobj:
cPickle.dump(self._model.bookmarks, fileobj)
def import_bookmarks(self):
filename = QFileDialog.getOpenFileName(self, _("Import Bookmarks"), '%s' % os.getcwdu(), _("Pickled Bookmarks (*.pickle)"))
if filename == '':
return
imported = None
with open(filename, 'r') as fileobj:
imported = cPickle.load(fileobj)
if imported != None:
bad = False
try:
@ -74,7 +76,7 @@ class BookmarkManager(QDialog, Ui_BookmarkManager):
break
except:
pass
if not bad:
bookmarks = self._model.bookmarks[:]
for bm in imported:
@ -88,32 +90,32 @@ class BookmarkTableModel(QAbstractTableModel):
def __init__(self, parent, bookmarks):
QAbstractTableModel.__init__(self, parent)
self.bookmarks = bookmarks[:]
def rowCount(self, parent):
if parent and parent.isValid():
return 0
return len(self.bookmarks)
def columnCount(self, parent):
if parent and parent.isValid():
return 0
return len(self.headers)
def data(self, index, role):
if role in (Qt.DisplayRole, Qt.EditRole):
ans = self.bookmarks[index.row()][0]
return NONE if ans is None else QVariant(ans)
return NONE
def setData(self, index, value, role):
if role == Qt.EditRole:
self.bookmarks[index.row()] = (qstring_to_unicode(value.toString()).strip(), self.bookmarks[index.row()][1])
self.emit(SIGNAL("dataChanged(QModelIndex, QModelIndex)"), index, index)
return True
return False
def flags(self, index):
flags = QAbstractTableModel.flags(self, index)
flags |= Qt.ItemIsEditable
@ -126,7 +128,7 @@ class BookmarkTableModel(QAbstractTableModel):
return QVariant(self.headers[section])
else:
return QVariant(section+1)
def remove_row(self, row):
self.beginRemoveRows(QModelIndex(), row, row)
del self.bookmarks[row]

View File

@ -77,7 +77,7 @@ Device Integration
What devices does |app| support?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At the moment |app| has full support for the SONY PRS 500/505/700, Cybook Gen 3, Amazon Kindle 1/2, Netronix EB600, Ectaco Jetbook, BeBook/BeBook Mini and the iPhone. In addition, using the :guilabel:`Save to disk` function you can use it with any ebook reader that exports itself as a USB disk.
At the moment |app| has full support for the SONY PRS 500/505/700, Cybook Gen 3, Amazon Kindle 1/2/DX, Netronix EB600, Ectaco Jetbook, BeBook/BeBook Mini and the iPhone. In addition, using the :guilabel:`Save to disk` function you can use it with any ebook reader that exports itself as a USB disk.
I used |app| to transfer some books to my reader, and now the SONY software hangs every time I connect the reader?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -4,9 +4,9 @@
#
msgid ""
msgstr ""
"Project-Id-Version: calibre 0.6.0b3\n"
"POT-Creation-Date: 2009-06-10 13:26+PDT\n"
"PO-Revision-Date: 2009-06-10 13:26+PDT\n"
"Project-Id-Version: calibre 0.6.0b5\n"
"POT-Creation-Date: 2009-06-11 15:24+PDT\n"
"PO-Revision-Date: 2009-06-11 15:24+PDT\n"
"Last-Translator: Automatically generated\n"
"Language-Team: LANGUAGE\n"
"MIME-Version: 1.0\n"
@ -58,12 +58,12 @@ msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/mobi/reader.py:69
#: /home/kovid/work/calibre/src/calibre/ebooks/mobi/reader.py:78
#: /home/kovid/work/calibre/src/calibre/ebooks/mobi/reader.py:149
#: /home/kovid/work/calibre/src/calibre/ebooks/mobi/reader.py:531
#: /home/kovid/work/calibre/src/calibre/ebooks/mobi/reader.py:715
#: /home/kovid/work/calibre/src/calibre/ebooks/mobi/reader.py:535
#: /home/kovid/work/calibre/src/calibre/ebooks/mobi/reader.py:719
#: /home/kovid/work/calibre/src/calibre/ebooks/odt/input.py:44
#: /home/kovid/work/calibre/src/calibre/ebooks/odt/input.py:46
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:791
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:796
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:798
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:803
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/reader.py:162
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/reader.py:165
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/transforms/jacket.py:82
@ -363,7 +363,7 @@ msgstr ""
#: /home/kovid/work/calibre/src/calibre/devices/prs505/driver.py:151
#: /home/kovid/work/calibre/src/calibre/devices/usbms/driver.py:133
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/scheduler.py:467
#: /home/kovid/work/calibre/src/calibre/gui2/tags.py:50
#: /home/kovid/work/calibre/src/calibre/gui2/tag_view.py:80
#: /home/kovid/work/calibre/src/calibre/library/database2.py:937
#: /home/kovid/work/calibre/src/calibre/library/database2.py:941
#: /home/kovid/work/calibre/src/calibre/library/database2.py:1259
@ -1082,51 +1082,51 @@ msgstr ""
msgid "Set book ID"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:77
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:78
msgid "Enable autorotation of images that are wider than the screen width."
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:81
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:82
msgid "Set the space between words in pts. Default is %default"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:84
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:85
msgid "Add a header to all the pages with title and author."
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:87
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:88
msgid "Set the format of the header. %a is replaced by the author and %t by the title. Default is %default"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:91
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:92
msgid "Add extra spacing below the header. Default is %default pt."
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:94
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:95
msgid "Minimum paragraph indent (the indent of the first line of a paragraph) in pts. Default: %default"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:99
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:100
msgid "Render tables in the HTML as images (useful if the document has large or complex tables)"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:104
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:105
msgid "Multiply the size of text in rendered tables by this factor. Default is %default"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:108
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:109
msgid "The serif family of fonts to embed"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:111
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:112
msgid "The sans-serif family of fonts to embed"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:114
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:115
msgid "The monospace family of fonts to embed"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:139
#: /home/kovid/work/calibre/src/calibre/ebooks/lrf/output.py:140
msgid "Comic"
msgstr ""
@ -1178,7 +1178,7 @@ msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/library.py:942
#: /home/kovid/work/calibre/src/calibre/gui2/library.py:1002
#: /home/kovid/work/calibre/src/calibre/gui2/status.py:60
#: /home/kovid/work/calibre/src/calibre/gui2/tags.py:50
#: /home/kovid/work/calibre/src/calibre/gui2/tag_view.py:80
msgid "Tags"
msgstr ""
@ -1186,7 +1186,7 @@ msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/library.py:124
#: /home/kovid/work/calibre/src/calibre/gui2/library.py:319
#: /home/kovid/work/calibre/src/calibre/gui2/status.py:59
#: /home/kovid/work/calibre/src/calibre/gui2/tags.py:50
#: /home/kovid/work/calibre/src/calibre/gui2/tag_view.py:80
msgid "Series"
msgstr ""
@ -1356,74 +1356,74 @@ msgstr ""
msgid "Disable compression of the file contents."
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1164
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1177
msgid "Cover"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1165
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1178
msgid "Title Page"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1166
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1179
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/transforms/htmltoc.py:15
#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main.py:48
#: /home/kovid/work/calibre/src/calibre/gui2/viewer/main_ui.py:166
msgid "Table of Contents"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1167
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1180
msgid "Index"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1168
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1181
msgid "Glossary"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1169
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1182
msgid "Acknowledgements"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1170
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1183
msgid "Bibliography"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1171
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1184
msgid "Colophon"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1172
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1185
msgid "Copyright"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1173
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1186
msgid "Dedication"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1174
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1187
msgid "Epigraph"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1175
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1188
msgid "Foreword"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1176
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1189
msgid "List of Illustrations"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1177
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1190
msgid "List of Tables"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1178
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1191
msgid "Notes"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1179
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1192
msgid "Preface"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1180
#: /home/kovid/work/calibre/src/calibre/ebooks/oeb/base.py:1193
msgid "Main Text"
msgstr ""
@ -2791,7 +2791,7 @@ msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/dialogs/config.py:212
#: /home/kovid/work/calibre/src/calibre/gui2/library.py:309
#: /home/kovid/work/calibre/src/calibre/gui2/status.py:57
#: /home/kovid/work/calibre/src/calibre/gui2/tags.py:50
#: /home/kovid/work/calibre/src/calibre/gui2/tag_view.py:80
msgid "Formats"
msgstr ""
@ -4327,7 +4327,7 @@ msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/library.py:302
#: /home/kovid/work/calibre/src/calibre/gui2/library.py:308
#: /home/kovid/work/calibre/src/calibre/gui2/library.py:313
#: /home/kovid/work/calibre/src/calibre/gui2/widgets.py:374
#: /home/kovid/work/calibre/src/calibre/gui2/widgets.py:376
msgid "None"
msgstr ""
@ -5028,11 +5028,11 @@ msgstr ""
msgid "Click to browse books by tags"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/tags.py:50
#: /home/kovid/work/calibre/src/calibre/gui2/tag_view.py:80
msgid "Authors"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/tags.py:50
#: /home/kovid/work/calibre/src/calibre/gui2/tag_view.py:80
msgid "Publishers"
msgstr ""
@ -5076,16 +5076,19 @@ msgstr ""
msgid "Export Bookmarks"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/viewer/bookmarkmanager.py:52
#: /home/kovid/work/calibre/src/calibre/gui2/viewer/bookmarkmanager.py:60
msgid "Pickled Bookmarks (*.pickle)"
#: /home/kovid/work/calibre/src/calibre/gui2/viewer/bookmarkmanager.py:54
msgid "Saved Bookmarks (*.pickle)"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/viewer/bookmarkmanager.py:60
#: /home/kovid/work/calibre/src/calibre/gui2/viewer/bookmarkmanager.py:62
msgid "Import Bookmarks"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/viewer/bookmarkmanager.py:87
#: /home/kovid/work/calibre/src/calibre/gui2/viewer/bookmarkmanager.py:62
msgid "Pickled Bookmarks (*.pickle)"
msgstr ""
#: /home/kovid/work/calibre/src/calibre/gui2/viewer/bookmarkmanager.py:89
msgid "Name"
msgstr ""