From: W. Trevor King Date: Mon, 19 Mar 2012 13:04:42 +0000 (-0400) Subject: Add .channels() method to Subdevice class. X-Git-Tag: 0.5~35 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1e324c0a3cdabf62984ffc825b5331dbef16bdef;p=pycomedi.git Add .channels() method to Subdevice class. --- diff --git a/pycomedi/subdevice.pyx b/pycomedi/subdevice.pyx index a38c434..9042e7a 100644 --- a/pycomedi/subdevice.pyx +++ b/pycomedi/subdevice.pyx @@ -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)