From 23a448185801e7bd8c30ba51238098a2435c1134 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 19 Jan 2016 09:00:43 +0530 Subject: [PATCH] Workaround for broken rev in pnp id for PRS 650 --- src/calibre/devices/winusb.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/winusb.py b/src/calibre/devices/winusb.py index 1c68ed6d31..83d06e7306 100644 --- a/src/calibre/devices/winusb.py +++ b/src/calibre/devices/winusb.py @@ -408,7 +408,7 @@ _devid_pat = None def devid_pat(): global _devid_pat if _devid_pat is None: - _devid_pat = re.compile(r'VID_([a-f0-9]{4})&PID_([a-f0-9]{4})&REV_([a-f0-9]{4})', re.I) + _devid_pat = re.compile(r'VID_([a-f0-9]{4})&PID_([a-f0-9]{4})&REV_([a-f0-9:]{4})', re.I) return _devid_pat @@ -646,6 +646,9 @@ class USBDevice(_USBDevice): return 'USBDevice(vendor_id=%s product_id=%s bcd=%s devid=%s devinst=%s)' % ( r(self.vendor_id), r(self.product_id), r(self.bcd), self.devid, self.devinst) +def parse_hex(x): + return int(x.replace(':', 'a'), 16) + def iterusbdevices(): buf = None pat = devid_pat() @@ -658,7 +661,7 @@ def iterusbdevices(): yield USBDevice(None, None, None, devid, devinfo.DevInst) else: try: - vid, pid, bcd = map(lambda x:int(x, 16), m.group(1, 2, 3)) + vid, pid, bcd = map(parse_hex, m.group(1, 2, 3)) except Exception: yield USBDevice(None, None, None, devid, devinfo.DevInst) else: