Author: bugman Date: Sun Jun 22 18:10:03 2008 New Revision: 6419 URL: http://svn.gna.org/viewcvs/relax?rev=6419&view=rev Log: Fixes to the PipeContainer.xml_write() method. Modified: 1.3/data/__init__.py 1.3/data/pipe_container.py 1.3/data/relax_xml.py Modified: 1.3/data/__init__.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/__init__.py?rev=6419&r1=6418&r2=6419&view=diff ============================================================================== --- 1.3/data/__init__.py (original) +++ 1.3/data/__init__.py Sun Jun 22 18:10:03 2008 @@ -183,8 +183,17 @@ # Set the relax version number. top_elem.setAttribute('version', version) - # Create the data pipe element. - self[self.current_pipe].xml_write(xmldoc, top_elem) + # Create the pipe XML element and add it to the top level XML element. + pipe_elem = xmldoc.createElement('pipe') + top_elem.appendChild(pipe_elem) + + # Set the data pipe attributes. + pipe_elem.setAttribute('desc', 'The contents of a relax data pipe') + pipe_elem.setAttribute('name', self.current_pipe) + pipe_elem.setAttribute('type', self[self.current_pipe].pipe_type) + + # Fill the data pipe XML element. + self[self.current_pipe].xml_write(xmldoc, pipe_elem) # Write out the XML file. xml.dom.ext.PrettyPrint(xmldoc, file) Modified: 1.3/data/pipe_container.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/pipe_container.py?rev=6419&r1=6418&r2=6419&view=diff ============================================================================== --- 1.3/data/pipe_container.py (original) +++ 1.3/data/pipe_container.py Sun Jun 22 18:10:03 2008 @@ -28,7 +28,7 @@ from diff_tensor import DiffTensorData from mol_res_spin import MoleculeList from prototype import Prototype -from relax_xml import create_top_level +from relax_xml import fill_object_contents class PipeContainer(Prototype): @@ -131,26 +131,28 @@ return True - def xml_write(self, file): - """Create a XML elements for the current data pipe. + def xml_write(self, doc, elem): + """Create a XML element for the current data pipe. - @param file: The open file object. - @type file: file + @param doc: The XML document object. + @type doc: xml.dom.minidom.Document instance + @param elem: The XML element to add the pipe XML element to. + @type elem: XML element object """ # Add all simple python objects within the PipeContainer to the global element. - global_elem = xmldoc.createElement('global') - pipe_elem.appendChild(global_elem) + global_elem = doc.createElement('global') + elem.appendChild(global_elem) global_elem.setAttribute('desc', 'Global data located in the top level of the data pipe') - fill_object_contents(xmldoc, global_elem, object=self, blacklist=['diff_tensor', 'hybrid_pipes', 'is_empty', 'mol', 'pipe_type', 'structure']) + fill_object_contents(doc, global_elem, object=self, blacklist=['diff_tensor', 'hybrid_pipes', 'mol', 'pipe_type', 'structure'] + self.__class__.__dict__.keys()) # Hybrid info. - create_hybrid_elem(xmldoc, pipe_elem) + create_hybrid_elem(doc, elem) # Add the diffusion tensor data. if hasattr(cdp, 'diff_tensor'): - create_diff_elem(xmldoc, pipe_elem) + create_diff_elem(doc, elem) # Add the structural data, if it exists. if hasattr(cdp, 'structure'): - create_str_elem(xmldoc, pipe_elem) + create_str_elem(doc, elem) Modified: 1.3/data/relax_xml.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/relax_xml.py?rev=6419&r1=6418&r2=6419&view=diff ============================================================================== --- 1.3/data/relax_xml.py (original) +++ 1.3/data/relax_xml.py Sun Jun 22 18:10:03 2008 @@ -73,30 +73,6 @@ list_elem.appendChild(text_val) -def create_pipe_elem(doc, elem): - """Create an XML element for the data pipe, and add data pipe info as attributes. - - @param doc: The XML document object. - @type doc: xml.dom.minidom.Document instance - @param elem: The element to add the pipe element to. - @type elem: XML element object - @return: The data pipe element. - @rtype: XML element object - """ - - # Create the pipe element and add it to the higher level element. - pipe_elem = doc.createElement('pipe') - elem.appendChild(pipe_elem) - - # Set the data pipe attributes. - pipe_elem.setAttribute('desc', 'The contents of a relax data pipe') - pipe_elem.setAttribute('name', ds.current_pipe) - pipe_elem.setAttribute('type', ds[ds.current_pipe].pipe_type) - - # Return the pipe element. - return pipe_elem - - def create_str_elem(doc, elem): """Create an XML element for the structural information.