From dd62e49a87fa1fe307b88edb928ac408ee93377e Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Thu, 7 Jul 2011 19:18:15 +0100 Subject: [PATCH] Fix for device_db --- src/calibre/devices/apple/driver.py | 1 + src/calibre/devices/interface.py | 3 +++ src/calibre/devices/prs505/driver.py | 1 + src/calibre/gui2/preferences/plugboard.py | 7 ++++--- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/calibre/devices/apple/driver.py b/src/calibre/devices/apple/driver.py index ed17302eb2..3dc71f1292 100644 --- a/src/calibre/devices/apple/driver.py +++ b/src/calibre/devices/apple/driver.py @@ -107,6 +107,7 @@ class DriverBase(DeviceConfig, DevicePlugin): FORMATS = ['epub', 'pdf'] USER_CAN_ADD_NEW_FORMATS = False KEEP_TEMP_FILES_AFTER_UPLOAD = True + CAN_DO_DEVICE_DB_PLUGBOARD = True # Hide the standard customization widgets SUPPORTS_SUB_DIRS = False diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index 925f9eafd0..7537e18db3 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -49,6 +49,9 @@ class DevicePlugin(Plugin): #: Whether the metadata on books can be set via the GUI. CAN_SET_METADATA = ['title', 'authors', 'collections'] + #: Whether the device can handle device_db metadata plugboards + CAN_DO_DEVICE_DB_PLUGBOARD = False + # Set this to None if the books on the device are files that the GUI can # access in order to add the books from the device to the library BACKLOADING_ERROR_MESSAGE = _('Cannot get files from this device') diff --git a/src/calibre/devices/prs505/driver.py b/src/calibre/devices/prs505/driver.py index 2f962fc218..5898c80baf 100644 --- a/src/calibre/devices/prs505/driver.py +++ b/src/calibre/devices/prs505/driver.py @@ -28,6 +28,7 @@ class PRS505(USBMS): FORMATS = ['epub', 'lrf', 'lrx', 'rtf', 'pdf', 'txt'] CAN_SET_METADATA = ['title', 'authors', 'collections'] + CAN_DO_DEVICE_DB_PLUGBOARD = True VENDOR_ID = [0x054c] #: SONY Vendor Id PRODUCT_ID = [0x031e] diff --git a/src/calibre/gui2/preferences/plugboard.py b/src/calibre/gui2/preferences/plugboard.py index f0a1a5fd04..cc94b5e42a 100644 --- a/src/calibre/gui2/preferences/plugboard.py +++ b/src/calibre/gui2/preferences/plugboard.py @@ -58,7 +58,9 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): self.device_to_formats_map = {} for device in device_plugins(): n = device_name_for_plugboards(device) - self.device_to_formats_map[n] = device.FORMATS + self.device_to_formats_map[n] = set(device.FORMATS) + if getattr(device, 'CAN_DO_DEVICE_DB_PLUGBOARD', False): + self.device_to_formats_map[n].add('device_db') if n not in self.devices: self.devices.append(n) self.devices.sort(cmp=lambda x, y: cmp(x.lower(), y.lower())) @@ -241,8 +243,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form): if self.current_format != plugboard_any_format_value and \ self.current_device in self.device_to_formats_map: allowable_formats = self.device_to_formats_map[self.current_device] - if (self.current_format not in allowable_formats and - self.current_format != 'device_db'): + if self.current_format not in allowable_formats: error_dialog(self, '', _('The {0} device does not support the {1} format.'). format(self.current_device, self.current_format),