Ejemplo n.º 1
0
 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))
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
 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