]> sigrok.org Git - libsigrok.git/commitdiff
python: Support keyword arguments to scan()
authorMartin Ling <redacted>
Wed, 24 Apr 2013 16:48:04 +0000 (17:48 +0100)
committerUwe Hermann <redacted>
Wed, 24 Apr 2013 21:20:47 +0000 (23:20 +0200)
bindings/python/sigrok/core/classes.py

index 2998b4126b6bf2a26a3ba9306410e5e7b18f74e9..e490b34db22d12242b7951f0f828feb498ff75cf 100644 (file)
@@ -115,11 +115,20 @@ class Driver(object):
     def name(self):
         return self.struct.name
 
-    def scan(self):
+    def scan(self, **kwargs):
         if not self._initialized:
             check(sr_driver_init(self.context.struct, self.struct))
             self._initialized = True
-        device_list = sr_driver_scan(self.struct, None)
+        options = []
+        for name, value in kwargs.items():
+            key = getattr(ConfigKey, name.upper())
+            src = sr_config()
+            src.key = key.id
+            src.value = python_to_gvariant(value)
+            options.append(src.this)
+        option_list = python_to_gslist(options)
+        device_list = sr_driver_scan(self.struct, option_list)
+        g_slist_free(option_list)
         devices = [Device(self, gpointer_to_sr_dev_inst_ptr(ptr))
             for ptr in gslist_to_python(device_list)]
         g_slist_free(device_list)