def run(self, ctx, **k): event = self.params(self.ctx) if self.new_hc is None: raise SyntaxError( u"‹fs20 switch› without sub-statements does nothing!") if self.hc is None: if self.code is None: raise SyntaxError( u"A new ‹fs20 switch› needs a ‹code› sub-statement!") self.hc = SwitchGroup(self.code, SName(event)) elif self.code is not None: self.hc.code = self.code ## update for s in self.old_sw: if s.parent != self.hc: raise RuntimeError( "The named device has house code %d, not %d" % (to_hc(s.parent.code), to_hc(self.hc.code))) s.delete() for s in self.new_sw: if s.code in self.hc.devs: raise RuntimeError(u"The code ‹%d› is already known in ‹%d›" % (to_dev(s.code), to_hc(self.hc.code))) s.parent = self.hc s.add()
def list(self): yield super(Switch,self) yield ("code",to_dev(self.code)) yield ("parent",self.parent.name) yield ("parentcode", to_hc(self.parent.code)) for d in self.does: yield ("does",d) if self.state is not None: yield ("state",self.state) if self.handler: yield ("via",self.handler.name)
def list(self): yield super(Switch, self) yield ("code", to_dev(self.code)) yield ("parent", self.parent.name) yield ("parentcode", to_hc(self.parent.code)) for d in self.does: yield ("does", d) if self.state is not None: yield ("state", self.state) if self.handler: yield ("via", self.handler.name)
def run(self,ctx,**k): event = self.params(self.ctx) if self.new_hc is None: raise SyntaxError(u"‹fs20 switch› without sub-statements does nothing!") if self.hc is None: if self.code is None: raise SyntaxError(u"A new ‹fs20 switch› needs a ‹code› sub-statement!") self.hc = SwitchGroup(self.code, SName(event)) elif self.code is not None: self.hc.code = self.code ## update for s in self.old_sw: if s.parent != self.hc: raise RuntimeError("The named device has house code %d, not %d" % (to_hc(s.parent.code),to_hc(self.hc.code))) s.delete() for s in self.new_sw: if s.code in self.hc.devs: raise RuntimeError(u"The code ‹%d› is already known in ‹%d›" % (to_dev(s.code),to_hc(self.hc.code))) s.parent = self.hc s.add()
def info(self): return str(self.parent.name)+" "+str(to_dev(self.code))
def info(self): return str(self.parent.name) + " " + str(to_dev(self.code))