From: Martin Ling Date: Wed, 24 Apr 2013 16:48:04 +0000 (+0100) Subject: python: Support keyword arguments to scan() X-Git-Tag: dsupstream~66 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3124e80bfe6189d52c5aec9a8c1cacb6ee852b91;p=libsigrok.git python: Support keyword arguments to scan() --- diff --git a/bindings/python/sigrok/core/classes.py b/bindings/python/sigrok/core/classes.py index 2998b412..e490b34d 100644 --- a/bindings/python/sigrok/core/classes.py +++ b/bindings/python/sigrok/core/classes.py @@ -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)