From a79225f8ce8a4473e60590537d21c7b97c596055 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 2 Jan 2014 00:45:06 +0530 Subject: [PATCH] Fix #1265356 [Duplicate "0x" in hexadecimal strings](https://bugs.launchpad.net/calibre/+bug/1265356) --- .../gui2/preferences/device_user_defined.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/preferences/device_user_defined.py b/src/calibre/gui2/preferences/device_user_defined.py index 13721689f1..1448d8c11b 100644 --- a/src/calibre/gui2/preferences/device_user_defined.py +++ b/src/calibre/gui2/preferences/device_user_defined.py @@ -64,13 +64,18 @@ class UserDefinedDevice(QDialog): new_devices = after['device_set'] - before['device_set'] res = '' 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: - res = _('USB Vendor ID (in hex)') + ': 0x' + \ - after['device_details'][d][0] + '\n' - res += _('USB Product ID (in hex)') + ': 0x' + \ - after['device_details'][d][1] + '\n' - res += _('USB Revision ID (in hex)') + ': 0x' + \ - after['device_details'][d][2] + '\n' + res = _('USB Vendor ID (in hex)') + ': ' + \ + fmtid(after['device_details'][d][0]) + '\n' + res += _('USB Product ID (in hex)') + ': ' + \ + fmtid(after['device_details'][d][1]) + '\n' + res += _('USB Revision ID (in hex)') + ': ' + \ + fmtid(after['device_details'][d][2]) + '\n' if iswindows: # sort the drives by the order number for i,d in enumerate(sorted(new_drives,