diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index 7f79877bd5..1ad189db1a 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -8,6 +8,7 @@ __builtin__.__dict__['dynamic_property'] = lambda func: func(None) from math import floor from functools import partial +print ("Hello, world!") warnings.simplefilter('ignore', DeprecationWarning) try: os.getcwdu() diff --git a/src/calibre/devices/eb600/driver.py b/src/calibre/devices/eb600/driver.py index 0e616e369b..0f5271086a 100644 --- a/src/calibre/devices/eb600/driver.py +++ b/src/calibre/devices/eb600/driver.py @@ -57,6 +57,14 @@ class TOLINO(EB600): FORMATS = ['epub', 'pdf', 'txt'] BCD = [0x226] + def linux_swap_drives(self, drives): + if len(drives) < 2 or not drives[1] or not drives[2]: return drives + drives = list(drives) + t = drives[0] + drives[0] = drives[1] + drives[1] = t + return tuple(drives) + class COOL_ER(EB600): name = 'Cool-er device interface' diff --git a/src/calibre/devices/misc.py b/src/calibre/devices/misc.py index 7a9f51167d..d7a4531fc7 100644 --- a/src/calibre/devices/misc.py +++ b/src/calibre/devices/misc.py @@ -446,6 +446,7 @@ class WAYTEQ(USBMS): return drives def linux_swap_drives(self, drives): + # See https://bugs.launchpad.net/bugs/1151901 if len(drives) < 2 or not drives[1] or not drives[2]: return drives drives = list(drives) t = drives[0] diff --git a/src/calibre/ebooks/oeb/transforms/split.py b/src/calibre/ebooks/oeb/transforms/split.py index 91d5a3feac..5ba653aa66 100644 --- a/src/calibre/ebooks/oeb/transforms/split.py +++ b/src/calibre/ebooks/oeb/transforms/split.py @@ -242,7 +242,6 @@ class FlowSplitter(object): self.trees[i:i+1] = [before_tree, after_tree] break - self.trees.append(tree) trees, ids = [], set([]) for tree in self.trees: root = tree.getroot() diff --git a/src/calibre/ebooks/pdf/render/engine.py b/src/calibre/ebooks/pdf/render/engine.py index 3e9497a3d3..6e6347cab2 100644 --- a/src/calibre/ebooks/pdf/render/engine.py +++ b/src/calibre/ebooks/pdf/render/engine.py @@ -315,6 +315,8 @@ class PdfDevice(QPaintDevice): # {{{ self.page_width, self.page_height = page_size self.body_width = self.page_width - left_margin - right_margin self.body_height = self.page_height - top_margin - bottom_margin + self.left_margin, self.right_margin = left_margin, right_margin + self.top_margin, self.bottom_margin = top_margin, bottom_margin self.engine = PdfEngine(file_object, self.page_width, self.page_height, left_margin, top_margin, right_margin, bottom_margin, self.width(), self.height(), @@ -351,6 +353,14 @@ class PdfDevice(QPaintDevice): # {{{ def init_page(self): self.engine.init_page() + @property + def full_page_rect(self): + page_width = self.page_width * self.xdpi / 72.0 + lm = self.left_margin * self.xdpi / 72.0 + page_height = self.page_height * self.ydpi / 72.0 + tm = self.top_margin * self.ydpi / 72.0 + return (-lm, -tm, page_width, page_height) + @property def current_page_num(self): return self.engine.current_page_num diff --git a/src/calibre/ebooks/pdf/render/from_html.py b/src/calibre/ebooks/pdf/render/from_html.py index fcfe7f3631..933bcefd17 100644 --- a/src/calibre/ebooks/pdf/render/from_html.py +++ b/src/calibre/ebooks/pdf/render/from_html.py @@ -106,7 +106,7 @@ def draw_image_page(page_rect, painter, p, preserve_aspect_ratio=True): page_rect.height()) dx = int((page_rect.width() - nnw)/2.) dy = int((page_rect.height() - nnh)/2.) - page_rect.moveTo(dx, dy) + page_rect.translate(dx, dy) page_rect.setHeight(nnh) page_rect.setWidth(nnw) painter.drawPixmap(page_rect, p, p.rect()) @@ -192,7 +192,7 @@ class PDFWriter(QObject): p.loadFromData(self.cover_data) if not p.isNull(): self.doc.init_page() - draw_image_page(QRect(0, 0, self.doc.width(), self.doc.height()), + draw_image_page(QRect(*self.doc.full_page_rect), self.painter, p, preserve_aspect_ratio=self.opts.preserve_cover_aspect_ratio) self.doc.end_page() diff --git a/src/calibre/linux.py b/src/calibre/linux.py index 7606c11f16..5f8ae31ce5 100644 --- a/src/calibre/linux.py +++ b/src/calibre/linux.py @@ -166,7 +166,7 @@ class ZshCompleter(object): # {{{ exclude = u"'(- *)'" h = opt.help or '' h = h.replace('"', "'").replace('[', '(').replace( - ']', ')').replace('\n', ' ').replace(':', '\\:') + ']', ')').replace('\n', ' ').replace(':', '\\:').replace('`', "'") h = h.replace('%default', type(u'')(opt.default)) arg = '' if opt.takes_value():