def addMethod(self, m): """ Adds a L{Method} to the interface """ if m.nargs == -1: m.nargs = len( [ a for a in marshal.genCompleteTypes( m.sigIn ) ] ) m.nret = len( [ a for a in marshal.genCompleteTypes( m.sigOut ) ] ) self.methods[ m.name ] = m self._xml = None
def addMethod(self, m): """ Adds a L{Method} to the interface """ if m.nargs == -1: m.nargs = len([a for a in marshal.genCompleteTypes(m.sigIn)]) m.nret = len([a for a in marshal.genCompleteTypes(m.sigOut)]) self.methods[m.name] = m self._xml = None
def addSignal(self, s): """ Adds a L{Signal} to the interface """ if s.nargs == -1: s.nargs = len( [ a for a in marshal.genCompleteTypes( s.sig ) ] ) self.signals[ s.name ] = s self._xml = None
def addSignal(self, s): """ Adds a L{Signal} to the interface """ if s.nargs == -1: s.nargs = len([a for a in marshal.genCompleteTypes(s.sig)]) self.signals[s.name] = s self._xml = None
def _getXml(self): # """ # @returns: an XML description of the interface # @rtype: C{string} # """ if self._xml is None: l = list() l.append(' <interface name="%s">' % (self.name, )) k = self.methods.keys() k.sort() for m in (self.methods[a] for a in k): l.append(' <method name="%s">' % (m.name, )) for arg_sig in marshal.genCompleteTypes(m.sigIn): l.append(' <arg direction="in" type="%s"/>' % (arg_sig, )) for arg_sig in marshal.genCompleteTypes(m.sigOut): l.append(' <arg direction="out" type="%s"/>' % (arg_sig, )) l.append(' </method>') k = self.signals.keys() k.sort() for s in (self.signals[a] for a in k): l.append(' <signal name="%s">' % (s.name, )) for arg_sig in marshal.genCompleteTypes(s.sig): l.append(' <arg type="%s"/>' % (arg_sig, )) l.append(' </signal>') k = self.properties.keys() k.sort() for p in (self.properties[a] for a in k): l.append(' <property name="%s" type="%s" access="%s">' % ( p.name, p.sig, p.access, )) l.append( ' <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="%s"/>' % (p.emits, )) l.append(' </property>') l.append(' </interface>') self._xml = '\n'.join(l) return self._xml
def _getXml(self): # """ # @returns: an XML description of the interface # @rtype: C{string} # """ if self._xml is None: l = [] l.append(' <interface name="%s">' % (self.name,)) k = sorted(six.iterkeys(self.methods)) for m in (self.methods[a] for a in k): l.append(' <method name="%s">' % (m.name,)) for arg_sig in marshal.genCompleteTypes(m.sigIn): l.append( ' <arg direction="in" type="%s"/>' % (arg_sig,)) for arg_sig in marshal.genCompleteTypes(m.sigOut): l.append( ' <arg direction="out" type="%s"/>' % (arg_sig,)) l.append(' </method>') k = sorted(six.iterkeys(self.signals)) for s in (self.signals[a] for a in k): l.append(' <signal name="%s">' % (s.name,)) for arg_sig in marshal.genCompleteTypes(s.sig): l.append(' <arg type="%s"/>' % (arg_sig,)) l.append(' </signal>') k = list(six.iterkeys(self.properties)) k.sort() for p in (self.properties[a] for a in k): l.append( ' <property name="%s" type="%s" access="%s">' % (p.name, p.sig, p.access,)) l.append( ' <annotation name="org.freedesktop.DBus.Property.' 'EmitsChangedSignal" value="%s"/>' % (p.emits,)) l.append(' </property>') l.append(' </interface>') self._xml = '\n'.join(l) return self._xml
def ae(self, sig, expected): self.assertEquals( list(m.genCompleteTypes(sig)), expected )
def ae(self, sig, expected): self.assertEquals(list(m.genCompleteTypes(sig)), expected)