def __init__(self, sim, dir): self.sim = sim self.dir = dir self.file = "federate.xml" if self.dir != None: xml = open(base_dir + os.sep + self.sim.dir + os.sep + self.dir + \ os.sep + "federate.xml", "r").read() self.federate = Federate.fromXml(xml) else: self.federate = Federate(name="", system="", description="") self.attributes = [] self.handlers = [] self.bindings = [] if self.federate.attributes: self.attributes = self.federate.attributes[0].attributes if self.federate.handlers: self.handlers = self.federate.handlers[0].events if self.federate.bindings: self.bindings = self.federate.bindings[0].variables for h in self.handlers: h.code = open(base_dir + os.sep + self.sim.dir + os.sep + \ self.dir + os.sep + h.file, "r").read()
def __init__(self,sim,dir): self.sim = sim self.dir = dir self.file = "federate.xml" if self.dir != None: xml = open(base_dir + os.sep + self.sim.dir + os.sep + self.dir + \ os.sep + "federate.xml", "r").read() self.federate = Federate.fromXml(xml) else: self.federate = Federate(name="",system="",description="") self.attributes = [] self.handlers = [] self.bindings = [] if self.federate.attributes: self.attributes = self.federate.attributes[0].attributes if self.federate.handlers: self.handlers = self.federate.handlers[0].events if self.federate.bindings: self.bindings = self.federate.bindings[0].variables for h in self.handlers: h.code = open(base_dir + os.sep + self.sim.dir + os.sep + \ self.dir + os.sep + h.file, "r").read()
class Fed: def __init__(self, sim, dir): self.sim = sim self.dir = dir self.file = "federate.xml" if self.dir != None: xml = open(base_dir + os.sep + self.sim.dir + os.sep + self.dir + \ os.sep + "federate.xml", "r").read() self.federate = Federate.fromXml(xml) else: self.federate = Federate(name="", system="", description="") self.attributes = [] self.handlers = [] self.bindings = [] if self.federate.attributes: self.attributes = self.federate.attributes[0].attributes if self.federate.handlers: self.handlers = self.federate.handlers[0].events if self.federate.bindings: self.bindings = self.federate.bindings[0].variables for h in self.handlers: h.code = open(base_dir + os.sep + self.sim.dir + os.sep + \ self.dir + os.sep + h.file, "r").read() def delete_self(self): # we won't actually delete the files yet. just to be on the safe # side. pass def save(self): xml = self.federate.toXml() if self.dir == None: self.dir = self.system open(base_dir + os.sep + self.sim.dir + os.sep + self.dir + \ os.sep + self.file, "w").write(xml) for event in self.federate.handlers[0].events: code = event.code open(base_dir + os.sep + self.sim.dir + os.sep + \ self.dir + os.sep + event.file,"w").write(code)
class Fed: def __init__(self,sim,dir): self.sim = sim self.dir = dir self.file = "federate.xml" if self.dir != None: xml = open(base_dir + os.sep + self.sim.dir + os.sep + self.dir + \ os.sep + "federate.xml", "r").read() self.federate = Federate.fromXml(xml) else: self.federate = Federate(name="",system="",description="") self.attributes = [] self.handlers = [] self.bindings = [] if self.federate.attributes: self.attributes = self.federate.attributes[0].attributes if self.federate.handlers: self.handlers = self.federate.handlers[0].events if self.federate.bindings: self.bindings = self.federate.bindings[0].variables for h in self.handlers: h.code = open(base_dir + os.sep + self.sim.dir + os.sep + \ self.dir + os.sep + h.file, "r").read() def delete_self(self): # we won't actually delete the files yet. just to be on the safe # side. pass def save(self): xml = self.federate.toXml() if self.dir == None: self.dir = self.system open(base_dir + os.sep + self.sim.dir + os.sep + self.dir + \ os.sep + self.file, "w").write(xml) for event in self.federate.handlers[0].events: code = event.code open(base_dir + os.sep + self.sim.dir + os.sep + \ self.dir + os.sep + event.file,"w").write(code)