Author: bugman Date: Thu Sep 10 19:24:30 2009 New Revision: 9502 URL: http://svn.gna.org/viewcvs/relax?rev=9502&view=rev Log: The relax data store to_xml() method now can add all data pipes to the XML file (or a subset). The results.write() method now asks to_xml() for just the current pipe to be stored, whereas state.save() supplies no 'pipes' argument to have all pipes stored. Modified: 1.3/data/__init__.py 1.3/generic_fns/results.py Modified: 1.3/data/__init__.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/__init__.py?rev=9502&r1=9501&r2=9502&view=diff ============================================================================== --- 1.3/data/__init__.py (original) +++ 1.3/data/__init__.py Thu Sep 10 19:24:30 2009 @@ -191,7 +191,7 @@ self[self.instance.current_pipe].from_xml(relax_node, dir=dir) - def to_xml(self, file): + def to_xml(self, file, pipes=None): """Create a XML document representation of the current data pipe. This method creates the top level XML document including all the information needed @@ -200,7 +200,18 @@ @param file: The open file object. @type file: file - """ + @param pipes: The name of the pipe, or list of pipes to place in the XML file. + @type pipes: str or list of str + """ + + # The pipes to include in the XML file. + if not pipes: + pipes = self.keys() + elif isinstance(pipes, str): + pipes = [pipes] + + # Sort the pipes. + pipes.sort() # Create the XML document object. xmldoc = xml.dom.minidom.Document() @@ -215,17 +226,19 @@ top_element.setAttribute('version', version) top_element.setAttribute('time', asctime()) - # Create the pipe XML element and add it to the top level XML element. - pipe_element = xmldoc.createElement('pipe') - top_element.appendChild(pipe_element) - - # Set the data pipe attributes. - pipe_element.setAttribute('desc', 'The contents of a relax data pipe') - pipe_element.setAttribute('name', self.instance.current_pipe) - pipe_element.setAttribute('type', self[self.instance.current_pipe].pipe_type) - - # Fill the data pipe XML element. - self[self.instance.current_pipe].to_xml(xmldoc, pipe_element) - + # Loop over the pipes. + for pipe in pipes: + # Create the pipe XML element and add it to the top level XML element. + pipe_element = xmldoc.createElement('pipe') + top_element.appendChild(pipe_element) + + # Set the data pipe attributes. + pipe_element.setAttribute('desc', 'The contents of a relax data pipe') + pipe_element.setAttribute('name', pipe) + pipe_element.setAttribute('type', self[pipe].pipe_type) + + # Fill the data pipe XML element. + self[pipe].to_xml(xmldoc, pipe_element) + # Write out the XML file. file.write(xmldoc.toprettyxml(indent=' ')) Modified: 1.3/generic_fns/results.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/results.py?rev=9502&r1=9501&r2=9502&view=diff ============================================================================== --- 1.3/generic_fns/results.py (original) +++ 1.3/generic_fns/results.py Thu Sep 10 19:24:30 2009 @@ -131,7 +131,7 @@ results_file = open_write_file(file_name=file, dir=directory, force=force, compress_type=compress_type, verbosity=verbosity) # Write the results. - ds.to_xml(results_file) + ds.to_xml(results_file, pipes=pipes.cdp_name()) # Close the results file. results_file.close()