[gnome-lirc-properties] Avoid duplicated entries in gnome-lirc-list script output
- From: Johannes Schmid <jhs src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-lirc-properties] Avoid duplicated entries in gnome-lirc-list script output
- Date: Thu, 17 Sep 2009 09:46:21 +0000 (UTC)
commit 6262e36a69bb41aac0329154dc9e059dc49712f2
Author: Johannes Schmid <jhs gnome org>
Date: Wed Sep 16 12:05:41 2009 +0200
Avoid duplicated entries in gnome-lirc-list script output
bin/lirc-receiver-list | 35 ++++++++++++++++++++++++++++++-----
1 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/bin/lirc-receiver-list b/bin/lirc-receiver-list
index 8101ecd..7e26468 100755
--- a/bin/lirc-receiver-list
+++ b/bin/lirc-receiver-list
@@ -185,7 +185,8 @@ def scan_kernel_driver(filename):
# iterate source code lines:
device_block = None
-
+ usb_comment = None
+ ids = []
for line, text in enumerate(driver_code.splitlines()):
match = re_usb_device_block_begin.search(text)
@@ -198,7 +199,7 @@ def scan_kernel_driver(filename):
if match:
device_block = None
continue
-
+
match = re_usb_device.search(text)
if match:
@@ -210,6 +211,12 @@ def scan_kernel_driver(filename):
# skip hardware that doesn't have unique USB ids:
if 0xffff == vendor_id or 0xffff == product_id:
continue
+
+ # skip duplicated hardware
+ if '%d:%d' % (vendor_id, product_id) in ids:
+ continue
+
+ ids.append('%d:%d' % (vendor_id, product_id))
# override vendor and product ids:
vendor_name = usb_overrides.get(
@@ -227,11 +234,15 @@ def scan_kernel_driver(filename):
logging.warning('%s:%d: Unknown Vendor (usb:%04x:%04x)',
srcname, line + 1, vendor_id, product_id)
vendor_name = 'Unknown Vendor (usb-%04X)' % vendor_id
+
if not product_name:
logging.warning('%s:%d: Unknown Product usb:%04x:%04x',
srcname, line + 1, vendor_id, product_id)
product_name = 'Unknown Product (usb-%04X-%04X)' % (vendor_id, product_id)
+ if usb_comment:
+ logging.warning('Using \'%s\' from comment instead', usb_comment)
+ product_name = usb_comment;
# drop company type suffixes:
vendor_name = re_company_suffix.sub('', vendor_name)
@@ -240,11 +251,11 @@ def scan_kernel_driver(filename):
section = '%s: %s' % (vendor_name, product_name)
# ensure section name is valid (could be more clever...)
- section = section.replace("[", "(")
- section = section.replace("]", ")")
+ section = section.replace('[', '(')
+ section = section.replace(']', ')')
receiver_sections.append(section)
-
+
print '# from %s, line %d' % (srcname, line + 1)
print '[%s]' % section
@@ -255,6 +266,14 @@ def scan_kernel_driver(filename):
print 'product-id = 0x%04x' % product_id
print 'vendor-id = 0x%04x' % vendor_id
print
+
+ # Save the comment, we could use it later to guess unkown product names
+ match = re_usb_comments.search(text)
+
+ if match:
+ usb_comment = match.group(1);
+ else:
+ usb_comment = None;
def print_database_header():
realname = pwd.getpwuid(os.getuid()).pw_gecos.split(',')[0]
@@ -332,6 +351,12 @@ if '__main__' == __name__:
re_usb_device_block_end = r'{\s*}'
re_usb_device_block_end = re.compile(re_usb_device_block_end)
+ re_usb_device_comment = r'/\*\s*\*/'
+ re_usb_device_comment = re.compile(re_usb_device_comment)
+
+ re_usb_comments = r'/\*\s*(.*?)\s*\*/'
+ re_usb_comments = re.compile(re_comments)
+
re_usb_device = r'USB_DEVICE\s*\(\s*([^,]*),\s*(.*?)\s*\)'
re_usb_device = re.compile(re_usb_device)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]