Fix #1265356 [Duplicate "0x" in hexadecimal strings](https://bugs.launchpad.net/calibre/+bug/1265356)

This commit is contained in:
Kovid Goyal 2014-01-02 00:45:06 +05:30
parent 3f21a83865
commit a79225f8ce

View File

@ -64,13 +64,18 @@ class UserDefinedDevice(QDialog):
new_devices = after['device_set'] - before['device_set'] new_devices = after['device_set'] - before['device_set']
res = '' res = ''
if (not iswindows or len(new_drives)) and len(new_devices) == 1: if (not iswindows or len(new_drives)) and len(new_devices) == 1:
def fmtid(x):
if not x.startswith('0x'):
x = '0x' + x
return x
for d in new_devices: for d in new_devices:
res = _('USB Vendor ID (in hex)') + ': 0x' + \ res = _('USB Vendor ID (in hex)') + ': ' + \
after['device_details'][d][0] + '\n' fmtid(after['device_details'][d][0]) + '\n'
res += _('USB Product ID (in hex)') + ': 0x' + \ res += _('USB Product ID (in hex)') + ': ' + \
after['device_details'][d][1] + '\n' fmtid(after['device_details'][d][1]) + '\n'
res += _('USB Revision ID (in hex)') + ': 0x' + \ res += _('USB Revision ID (in hex)') + ': ' + \
after['device_details'][d][2] + '\n' fmtid(after['device_details'][d][2]) + '\n'
if iswindows: if iswindows:
# sort the drives by the order number # sort the drives by the order number
for i,d in enumerate(sorted(new_drives, for i,d in enumerate(sorted(new_drives,