Add .channels() method to Subdevice class.
authorW. Trevor King <wking@drexel.edu>
Mon, 19 Mar 2012 13:04:42 +0000 (09:04 -0400)
committerW. Trevor King <wking@drexel.edu>
Mon, 19 Mar 2012 13:04:42 +0000 (09:04 -0400)
pycomedi/subdevice.pyx

index a38c4340429f75ef68a32e59e28f754fdac3c7ef..9042e7ae1e29e8925f1f894606d049f557b7f482 100644 (file)
@@ -156,6 +156,15 @@ cdef class Subdevice (object):
         insn.subdev = self.index
         return insn
 
+    def channels(self, **kwargs):
+        "Iterate through all available channels."
+        ret = []
+        for i in range(self.get_n_channels()):
+            #yield self.channel(i, **kwargs)
+            # Generators are not supported in Cython 0.14.1
+            ret.append(self.channel(i, **kwargs))
+        return ret
+
     def channel(self, index, factory=_Channel, **kwargs):
         "`Channel` instance for the `index`\ed channel."
         return factory(subdevice=self, index=index, **kwargs)