Fix #4080 (Can't SAVE TO DISK from DEVICE)

This commit is contained in:
Kovid Goyal 2009-11-30 12:49:30 -07:00
parent 0bcaa648bd
commit 7e45095b00
5 changed files with 10 additions and 2 deletions

View File

@ -34,6 +34,9 @@
tickets: [4040] tickets: [4040]
bug fixes: bug fixes:
- title: "Fix bug that prevented saving of books from a connected device to your computer on windows, for non SONY devices"
tickets: [4080]
- title: Reorganize Dutch language news sources into Belgium and Netherlands categories - title: Reorganize Dutch language news sources into Belgium and Netherlands categories
tickets: [4098] tickets: [4098]

View File

@ -5,6 +5,7 @@ Define the minimum interface that a device backend must satisfy to be used in
the GUI. A device backend must subclass the L{Device} class. See prs500.py for the GUI. A device backend must subclass the L{Device} class. See prs500.py for
a backend that implement the Device interface for the SONY PRS500 Reader. a backend that implement the Device interface for the SONY PRS500 Reader.
""" """
import os
from calibre.customize import Plugin from calibre.customize import Plugin
@ -29,6 +30,9 @@ class DevicePlugin(Plugin):
THUMBNAIL_HEIGHT = 68 # Height for thumbnails on device THUMBNAIL_HEIGHT = 68 # Height for thumbnails on device
# Whether the metadata on books can be set via the GUI. # Whether the metadata on books can be set via the GUI.
CAN_SET_METADATA = True CAN_SET_METADATA = True
#: Path separator for paths to books on device
path_sep = os.sep
def reset(self, key='-1', log_packets=False, report_progress=None) : def reset(self, key='-1', log_packets=False, report_progress=None) :
""" """

View File

@ -26,6 +26,7 @@ class PRS505(CLI, Device):
description = _('Communicate with the Sony PRS-300/505/500 eBook reader.') description = _('Communicate with the Sony PRS-300/505/500 eBook reader.')
author = _('Kovid Goyal and John Schember') author = _('Kovid Goyal and John Schember')
supported_platforms = ['windows', 'osx', 'linux'] supported_platforms = ['windows', 'osx', 'linux']
path_sep = '/'
FORMATS = ['epub', 'lrf', 'lrx', 'rtf', 'pdf', 'txt'] FORMATS = ['epub', 'lrf', 'lrx', 'rtf', 'pdf', 'txt']

View File

@ -799,7 +799,7 @@ class Manifest(object):
try: try:
data = etree.fromstring(data) data = etree.fromstring(data)
except etree.XMLSyntaxError, err: except etree.XMLSyntaxError, err:
self.log.exception('Initial parse failed:') self.oeb.log.exception('Initial parse failed:')
repl = lambda m: ENTITYDEFS.get(m.group(1), m.group(0)) repl = lambda m: ENTITYDEFS.get(m.group(1), m.group(0))
data = ENTITY_RE.sub(repl, data) data = ENTITY_RE.sub(repl, data)
try: try:

View File

@ -248,7 +248,7 @@ class DeviceManager(Thread):
def _save_books(self, paths, target): def _save_books(self, paths, target):
'''Copy books from device to disk''' '''Copy books from device to disk'''
for path in paths: for path in paths:
name = path.rpartition('/')[2] name = path.rpartition(getattr(self.device, 'path_sep', '/'))[2]
dest = os.path.join(target, name) dest = os.path.join(target, name)
if os.path.abspath(dest) != os.path.abspath(path): if os.path.abspath(dest) != os.path.abspath(path):
f = open(dest, 'wb') f = open(dest, 'wb')