Fix Cybook driver on windows

This commit is contained in:
Kovid Goyal 2009-01-06 16:58:52 -08:00
commit abeb671766
2 changed files with 20 additions and 6 deletions

View File

@ -1,5 +1,5 @@
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2009, John Schember <john at nachtimwald.com' __copyright__ = '2009, John Schember <john at nachtimwald.com>'
''' '''
''' '''
@ -20,6 +20,13 @@ class Book(object):
self.thumbnail = None self.thumbnail = None
self.tags = [] self.tags = []
@apply
def title_sorter():
doc = '''String to sort the title. If absent, title is returned'''
def fget(self):
return re.sub('^\s*A\s+|^\s*The\s+|^\s*An\s+', '', self.title).rstrip()
return property(doc=doc, fget=fget)
@apply @apply
def thumbnail(): def thumbnail():
return None return None

View File

@ -1,5 +1,5 @@
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2009, John Schember <john at nachtimwald.com' __copyright__ = '2009, John Schember <john at nachtimwald.com>'
''' '''
Device driver for Bookeen's Cybook Gen 3 Device driver for Bookeen's Cybook Gen 3
@ -19,7 +19,9 @@ class CYBOOKG3(Device):
VENDOR_ID = 0x0bda VENDOR_ID = 0x0bda
PRODUCT_ID = 0x0703 PRODUCT_ID = 0x0703
BCD = 0x110 BCD = 0x110
#THUMBNAIL_HEIGHT = 68 # Height for thumbnails on device
VENDOR_NAME = 'BOOKEEN'
PRODUCT_NAME = 'CYBOOK_GEN3'
MAIN_MEMORY_VOLUME_LABEL = 'Cybook Gen 3 Main Memory' MAIN_MEMORY_VOLUME_LABEL = 'Cybook Gen 3 Main Memory'
STORAGE_CARD_VOLUME_LABEL = 'Cybook Gen 3 Storage Card' STORAGE_CARD_VOLUME_LABEL = 'Cybook Gen 3 Storage Card'
@ -220,14 +222,19 @@ class CYBOOKG3(Device):
path = path.replace('card:', self._card_prefix[:-1]) path = path.replace('card:', self._card_prefix[:-1])
return path return path
@classmethod
def _windows_match_device(self, device_id): def windows_match_device(cls, device_id):
device_id = device_id.upper() device_id = device_id.upper()
if 'VEN_'+cls.VENDOR_NAME in device_id and \
'PROD_'+cls.PRODUCT_NAME in device_id:
return True
vid, pid = hex(cls.VENDOR_ID)[2:], hex(cls.PRODUCT_ID)[2:] vid, pid = hex(cls.VENDOR_ID)[2:], hex(cls.PRODUCT_ID)[2:]
while len(vid) < 4: vid = '0' + vid while len(vid) < 4: vid = '0' + vid
while len(pid) < 4: pid = '0' + pid while len(pid) < 4: pid = '0' + pid
if 'VID_'+vid in device_id and 'PID_'+pid in device_id: if 'VID_'+vid in device_id and 'PID_'+pid in device_id:
return True return True
return False return False
# This only supports Windows >= 2000 # This only supports Windows >= 2000
@ -236,7 +243,7 @@ class CYBOOKG3(Device):
wmi = __import__('wmi', globals(), locals(), [], -1) wmi = __import__('wmi', globals(), locals(), [], -1)
c = wmi.WMI() c = wmi.WMI()
for drive in c.Win32_DiskDrive(): for drive in c.Win32_DiskDrive():
if self._windows_match_device(str(drive.PNPDeviceID)): if self.__class__.windows_match_device(str(drive.PNPDeviceID)):
if drive.Partitions == 0: if drive.Partitions == 0:
continue continue
try: try: