X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FxmlManager.py;h=9c84cc18f0fedf5f7749340ae19781536dbb9dba;hb=5af0795a0f8264bd5d9ca43f384b689f7203b654;hp=ad454d8b6e9b313beea9e742d26067179434871e;hpb=2f5963f6298668374d3236955e3c28cc9af48711;p=tools%2Fsat.git diff --git a/src/xmlManager.py b/src/xmlManager.py index ad454d8..9c84cc1 100644 --- a/src/xmlManager.py +++ b/src/xmlManager.py @@ -62,7 +62,7 @@ class xmlLogFile(object): self.xmlroot.append(n) return n - def append_node(self, node_name, text): + def append_node_text(self, node_name, text): '''Append a new text to the node that has node_name as name :param node_name str: The name of the node on which append text @@ -74,6 +74,14 @@ class xmlLogFile(object): # append the text field.text += text + def append_node_attrib(self, node_name, attrib): + '''Append a new attributes to the node that has node_name as name + + :param node_name str: The name of the node on which append text + :param attrib dixt: The attrib to append + ''' + self.xmlroot.find(node_name).attrib.update(attrib) + class readXmlFile(object): '''Class to manage reading of an xml log file ''' @@ -86,15 +94,12 @@ class readXmlFile(object): etree_inst = etree.parse(filePath) self.xmlroot = etree_inst.parse(filePath) - def get_attrib_text(self, attribname): - '''Parse the root nodes and get all node that have the attribname. Return the list of [(value of attribname, text), ...] + def get_attrib(self, node_name): + '''Get the attibutes of the node node_name in self.xmlroot + + :param node_name str: the name of the node ''' - lres = [] - # Loop on all root nodes - for field in self.xmlroot: - if attribname in field.attrib: - lres.append((field.attrib[attribname], field.text)) - return lres + return self.xmlroot.find(node_name).attrib def get_node_text(self, node): '''Get the text of the first node that has name that corresponds to the parameter node