diff options
author | Christophe Fergeau <cfergeau@mandriva.com> | 2009-07-08 18:36:31 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@mandriva.com> | 2009-07-08 18:36:31 +0200 |
commit | cf36265bca0665da8120a906866165b4eed21c04 (patch) | |
tree | a4ef95b0bea066f4719d2f81262547e187312474 /tools | |
parent | 26effd14b33939857086b176d426748d1594307e (diff) |
change mpi format to make it more generic
instead of having VendorID and a list of ProductID (with the implied assumption
we are dealing with USB devices), we now just use a DeviceMatch field which
is a list of subsystem:VID:PID entries
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/fdi2mpi.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/fdi2mpi.py b/tools/fdi2mpi.py index 7422c26..110adb1 100755 --- a/tools/fdi2mpi.py +++ b/tools/fdi2mpi.py @@ -180,6 +180,25 @@ def mkfilename(attrs, current_vendor): return '%s-%s' % (v, m) +def usb_ids_to_device_match(attrs): + '''convert the USB IDs we gathered to a DeviceMatch string appropriate + for mpi files''' + + if not 'VendorID' in attrs['Device'].keys(): + return + + if not 'ProductID' in attrs['Device'].keys(): + attrs['Device']['ProductID'] = [ '*' ] + + device_match = '' + for id in attrs['Device']['ProductID']: + device_match += 'usb:'+ attrs['Device']['VendorID'][0] + ':' + id + ';' + + attrs['Device']['DeviceMatch'] = device_match + del attrs['Device']['VendorID'] + del attrs['Device']['ProductID'] + + def write_mpi(attrs, filename): '''Write mpi file for attrs.''' @@ -193,6 +212,8 @@ def write_mpi(attrs, filename): if product.startswith(vendor): attrs['Device']['Product'] = product[len(vendor):].strip() + usb_ids_to_device_match(attrs) + # only keep the most specific model name if attrs['Device'].has_key('Model'): attrs['Device']['Model'] = attrs['Device']['Model'][0] |