]> sigrok.org Git - libsigrok.git/commitdiff
python: Map probe group configuration to ProbeGroup attributes.
authorMartin Ling <redacted>
Sun, 21 Apr 2013 15:02:12 +0000 (16:02 +0100)
committerUwe Hermann <redacted>
Fri, 8 Nov 2013 00:03:17 +0000 (01:03 +0100)
bindings/python/sigrok/core/classes.py

index 4e0123508369ddbec8dad33620e1ef02c9528860..092cb1a7872e27ab3282b664c2127218642e135e 100644 (file)
@@ -237,6 +237,30 @@ class ProbeGroup(object):
     def __iter__(self):
         return iter(self.probes)
 
+    def __getattr__(self, name):
+        key = config_key(name)
+        data = new_gvariant_ptr_ptr()
+        try:
+            check(sr_config_get(self.device.driver.struct, self.device.struct,
+                self.struct, key, data))
+        except Error as error:
+            if error.errno == SR_ERR_NA:
+                raise NotImplementedError(
+                    "Probe group does not implement %s" % name)
+            else:
+                raise AttributeError
+        value = gvariant_ptr_ptr_value(data)
+        return gvariant_to_python(value)
+
+    def __setattr__(self, name, value):
+        try:
+            key = config_key(name)
+        except AttributeError:
+            super(ProbeGroup, self).__setattr__(name, value)
+            return
+        check(sr_config_set(self.device.struct, self.struct,
+            key, python_to_gvariant(value)))
+
     @property
     def name(self):
         return self.struct.name