Author: bugman Date: Mon Dec 20 16:15:56 2010 New Revision: 11913 URL: http://svn.gna.org/viewcvs/relax?rev=11913&view=rev Log: Added a check to make sure the relax save states can not be loaded by results.read(). Modified: 1.3/generic_fns/results.py Modified: 1.3/generic_fns/results.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/results.py?rev=11913&r1=11912&r2=11913&view=diff ============================================================================== --- 1.3/generic_fns/results.py (original) +++ 1.3/generic_fns/results.py Mon Dec 20 16:15:56 2010 @@ -35,6 +35,28 @@ from relax_errors import RelaxError, RelaxFileEmptyError from relax_io import extract_data, get_file_path, open_read_file, open_write_file, strip from specific_fns.setup import get_specific_fn + + +def check_xml(file_path, file): + """Check the XML results file. + + @param file_path: The path of the file. + @type file_path: str + @param file: The file object representing the results file. + @type file: file object + """ + + # Header line. + lines = [] + lines.append(file.readline()) + lines.append(file.readline()) + + # Be nice and go back to the start of the file. + file.seek(0) + + # A saved state!. + if search("<relax", lines[1]): + raise RelaxError("The file '%s' is a relax saved state and not a results file." % file_path) def determine_format(file): @@ -93,6 +115,10 @@ # XML results. if format == 'xml': + # Is this a results or save file? + check_xml(file_path, file) + + # Execute the data store XML parser. ds.from_xml(file, dir=dirname(file_path), pipe_to=pipes.cdp_name()) # Columnar results.