Salome HOME
Change log directory. It is now set in site.pyconf
[tools/sat.git] / src / xmlManager.py
index ad454d8b6e9b313beea9e742d26067179434871e..9c84cc18f0fedf5f7749340ae19781536dbb9dba 100644 (file)
@@ -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