mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix for device_db
This commit is contained in:
parent
a6f2aa1ef8
commit
dd62e49a87
@ -107,6 +107,7 @@ class DriverBase(DeviceConfig, DevicePlugin):
|
|||||||
FORMATS = ['epub', 'pdf']
|
FORMATS = ['epub', 'pdf']
|
||||||
USER_CAN_ADD_NEW_FORMATS = False
|
USER_CAN_ADD_NEW_FORMATS = False
|
||||||
KEEP_TEMP_FILES_AFTER_UPLOAD = True
|
KEEP_TEMP_FILES_AFTER_UPLOAD = True
|
||||||
|
CAN_DO_DEVICE_DB_PLUGBOARD = True
|
||||||
|
|
||||||
# Hide the standard customization widgets
|
# Hide the standard customization widgets
|
||||||
SUPPORTS_SUB_DIRS = False
|
SUPPORTS_SUB_DIRS = False
|
||||||
|
@ -49,6 +49,9 @@ class DevicePlugin(Plugin):
|
|||||||
#: 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 = ['title', 'authors', 'collections']
|
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
|
# 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
|
# access in order to add the books from the device to the library
|
||||||
BACKLOADING_ERROR_MESSAGE = _('Cannot get files from this device')
|
BACKLOADING_ERROR_MESSAGE = _('Cannot get files from this device')
|
||||||
|
@ -28,6 +28,7 @@ class PRS505(USBMS):
|
|||||||
|
|
||||||
FORMATS = ['epub', 'lrf', 'lrx', 'rtf', 'pdf', 'txt']
|
FORMATS = ['epub', 'lrf', 'lrx', 'rtf', 'pdf', 'txt']
|
||||||
CAN_SET_METADATA = ['title', 'authors', 'collections']
|
CAN_SET_METADATA = ['title', 'authors', 'collections']
|
||||||
|
CAN_DO_DEVICE_DB_PLUGBOARD = True
|
||||||
|
|
||||||
VENDOR_ID = [0x054c] #: SONY Vendor Id
|
VENDOR_ID = [0x054c] #: SONY Vendor Id
|
||||||
PRODUCT_ID = [0x031e]
|
PRODUCT_ID = [0x031e]
|
||||||
|
@ -58,7 +58,9 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.device_to_formats_map = {}
|
self.device_to_formats_map = {}
|
||||||
for device in device_plugins():
|
for device in device_plugins():
|
||||||
n = device_name_for_plugboards(device)
|
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:
|
if n not in self.devices:
|
||||||
self.devices.append(n)
|
self.devices.append(n)
|
||||||
self.devices.sort(cmp=lambda x, y: cmp(x.lower(), y.lower()))
|
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 \
|
if self.current_format != plugboard_any_format_value and \
|
||||||
self.current_device in self.device_to_formats_map:
|
self.current_device in self.device_to_formats_map:
|
||||||
allowable_formats = self.device_to_formats_map[self.current_device]
|
allowable_formats = self.device_to_formats_map[self.current_device]
|
||||||
if (self.current_format not in allowable_formats and
|
if self.current_format not in allowable_formats:
|
||||||
self.current_format != 'device_db'):
|
|
||||||
error_dialog(self, '',
|
error_dialog(self, '',
|
||||||
_('The {0} device does not support the {1} format.').
|
_('The {0} device does not support the {1} format.').
|
||||||
format(self.current_device, self.current_format),
|
format(self.current_device, self.current_format),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user