Fix for device_db

This commit is contained in:
Charles Haley 2011-07-07 19:18:15 +01:00
parent a6f2aa1ef8
commit dd62e49a87
4 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -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')

View File

@ -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]

View File

@ -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),