def __createMessage(self): multimap = collections.defaultdict(list) for key in self.commands: if key == 'mode': pass elif key == 'substitution': dict = util.convListToDict(self.commands.get(key)) for sub in dict: multimap['substitution'].append(str(sub)+":"+str(dict.get(sub))) elif key == 'update': dict = util.convListToDict(self.commands.get(key)) for sub in dict: multimap['update'].append(str(sub)+":"+str(dict.get(sub))) else: multimap[key].append(self.commands.get(key)) if self.__hasScript(): multimap['script'].append(self.script) return Message(header=Header(multimap=multimap))
def __createMessage(self): msg = MSG.Message(True) msg.initializeMessage(False) for key in self.commands: if key == 'mode': pass elif key == 'substitution': dict = util.convListToDict(self.commands.get(key)) for sub in dict: msg.addProperty(name='substitution',value=str(sub)+":"+str(dict.get(sub))) elif key == 'update': dict = util.convListToDict(self.commands.get(key)) for sub in dict: msg.addProperty(name='update',value=str(sub)+":"+str(dict.get(sub))) else: msg.addProperty(name=key,value=self.commands.get(key)) if self.__hasScript(): msg.addProperty(name='script',value=self.script) return msg.getXML()
def __readScript(self): # read the script if self.script == "": io = IO.InputOutput() io.setStream(sys.stdin) text = io.read() else: text = self.script # perform any substitutions if 'substitution' in self.commands: list = self.commands.get('substitution') dict = util.convListToDict(list) self.script = self.__transform(dict, text) else: self.script = text