mailr26072 - /trunk/data_store/exp_info.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on September 26, 2014 - 18:43:
Author: bugman
Date: Fri Sep 26 18:43:09 2014
New Revision: 26072

URL: http://svn.gna.org/viewcvs/relax?rev=26072&view=rev
Log:
Implemented the cdp.exp_info.from_xml() method to correctly restore the 
experimental info structure.

This fixes bug #22704 (https://gna.org/bugs/?22704), the corrupted relax 
state files after setting
the relax references via the bmrb.software, bmrb.display, or bmrb.write user 
functions.

This custom ExpInfo.from_xml() method is required to properly recreate the 
software, script and
citation list data structures of the cdp.exp_info data structure, as these 
are special RelaxListType
objects populated by Element objects (both from data_store.data_classes).


Modified:
    trunk/data_store/exp_info.py

Modified: trunk/data_store/exp_info.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/data_store/exp_info.py?rev=26072&r1=26071&r2=26072&view=diff
==============================================================================
--- trunk/data_store/exp_info.py        (original)
+++ trunk/data_store/exp_info.py        Fri Sep 26 18:43:09 2014
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2009-2013 Edward d'Auvergne                                  
 #
+# Copyright (C) 2009-2014 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -24,6 +24,7 @@
 
 # relax module imports.
 from data_store.data_classes import RelaxListType, Element
+from lib.xml import xml_to_object
 
 
 class ExpInfo(Element):
@@ -118,6 +119,44 @@
         self.citations.append(cite)
 
 
+    def from_xml(self, exp_info_node, file_version=1):
+        """Recreate the element data structure from the XML element node.
+
+        @param super_node:      The element XML node.
+        @type super_node:       xml.dom.minicompat.Element instance
+        @keyword file_version:  The relax XML version of the XML file.
+        @type file_version:     int
+        """
+
+        # Recreate the list structures.
+        list_node_names = ['citation_list', 'script_list', 'software_list']
+        list_subnode_names = ['citation', 'script', 'software']
+        list_str_names = ['citations', 'scripts', 'software']
+        for i in range(len(list_node_names)):
+            # Get the list node.
+            list_node = 
exp_info_node.getElementsByTagName(list_node_names[i])
+
+            # Necreate the structure, if the node exists.
+            if list_node:
+                # Initialise the data structure.
+                setattr(self, list_str_names[i], RelaxListType())
+                list_obj = getattr(self, list_str_names[i])
+
+                # Get all the subnodes.
+                list_nodes = 
list_node[0].getElementsByTagName(list_subnode_names[i])
+
+                # Loop over the nodes.
+                for node in list_nodes:
+                    # Add a blank container.
+                    list_obj.append(Element(name=node.tagName, 
desc=node.getAttribute('desc')))
+
+                    # Recreate the element.
+                    list_obj[-1].from_xml(node, file_version=file_version)
+
+        # Recreate all the other data structures.
+        xml_to_object(exp_info_node, self, file_version=file_version, 
blacklist=list_node_names)
+
+
     def get_cite_id_num(self, cite_id):
         """Return the citation ID number for the given citation ID string.
 




Related Messages


Powered by MHonArc, Updated Fri Sep 26 19:00:02 2014