]> sigrok.org Git - libsigrok.git/commitdiff
bindings/python: Add __repr__() to 'Channel' class
authorMarc Schink <redacted>
Fri, 29 Mar 2024 12:41:40 +0000 (13:41 +0100)
committerSoeren Apel <redacted>
Thu, 20 Nov 2025 18:01:37 +0000 (19:01 +0100)
The following lines show the class string representation before and
after this patch:

<sigrok.core.classes.Channel; proxy of <Swig Object of type 'std::shared_ptr< sigrok::Channel > *' at 0x7fdf4b29ff00> >
Channel (type=ChannelType.LOGIC, name='D0', index=0, enabled=True)

Signed-off-by: Marc Schink <redacted>
bindings/python/sigrok/core/classes.i

index efcd763e4d9aab52702d78fa1c75c7a68306d7c0..46672a3971feb9ef9bac8c144855722aa43d3365 100644 (file)
@@ -614,4 +614,13 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
     Context.create_logic_packet = _Context_create_logic_packet
 }
 
+%extend sigrok::Channel
+{
+%pythoncode
+{
+    def __repr__(self):
+        return _class_attribute_repr(self, ['type', 'name', 'index', 'enabled'])
+}
+}
+
 %include "doc_end.i"