def __get_exporter_blocks(self, cur_comp): comp_dom = XmlHandler.get_DOM(cur_comp) exp_blocks = "" for block in comp_dom.getElementsByTagName("block"): if block.getAttribute('export') == "yes": exp_blocks += block.toxml() return exp_blocks
def __get_datafiles(self): import base64 comp_dom = XmlHandler.get_DOM(self.__comprun_xml) for datafile in comp_dom.getElementsByTagName("datafile"): fname = datafile.getAttribute('filename') f = open(self.__datafile_dir +'/' + fname,'rb') fbin = base64.b64encode(f.read()) f.close() self.__datafiles.append( (fname,fbin) )
def rescue(self): """\brief substitute the exporter block and get the new xml running composition \return (\c RetVal) """ if self.__comprun_xml is None: return RetVal.CODE_FAILURE # delete the exporter blocks from the current running comp comprun_dom = XmlHandler.get_DOM(self.__comprun_xml) delete_dom = comprun_dom.createElement('delete') comprun_dom.childNodes[0].appendChild(delete_dom) for block in comprun_dom.getElementsByTagName("block"): if block.getAttribute('export') == "yes": delete_dom.appendChild(block) # add the exporter blocks from the new running comp add_dom = comprun_dom.createElement('add') comprun_dom.childNodes[0].appendChild(add_dom) comp_dom = XmlHandler.get_DOM(self.__comp_xml) for block in comp_dom.getElementsByTagName("block"): if block.getAttribute('export') == "yes": add_dom.appendChild(block) for label in ['general','install']: comprun_dom.childNodes[0].removeChild( comprun_dom.getElementsByTagName(label)[0] ) self.__comprun_xml = comprun_dom.toxml() print "----------------" print self.__comprun_xml print "----------------" self.__substitute_compvars() self.__substitute_vars(self.__intvars, self.__nodesrc) self.__substitute_vars(self.__extvars, self.__nodedst) print "**************" print self.__comprun_xml print "**************" return RetVal.CODE_SUCCESS
def __substitute_topovars(self, topovars): import re topo = self.__topodom.toxml() for (name, value) in topovars.iteritems(): topo = re.sub('"\s*@' + name + '\s*"', '"' + value + '"', topo) self.__topodom = XmlHandler.get_DOM(topo)
def dom(self): return XmlHandler.get_DOM(self.__template)