mailr26082 - in /branches/frame_order_cleanup: ./ 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 - 19:36:
Author: bugman
Date: Fri Sep 26 19:36:39 2014
New Revision: 26082

URL: http://svn.gna.org/viewcvs/relax?rev=26082&view=rev
Log:
Merged revisions 26071-26072 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r26071 | bugman | 2014-09-26 18:29:26 +0200 (Fri, 26 Sep 2014) | 10 lines
  
  Fix for the cdp.exp_info.software data structure setup.
  
  This is a partial fix for 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.
  
  The Element data container name was being replaced by the software name, 
making it impossible to
  restore from the XML.
........
  r26072 | bugman | 2014-09-26 18:43:09 +0200 (Fri, 26 Sep 2014) | 10 lines
  
  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:
    branches/frame_order_cleanup/   (props changed)
    branches/frame_order_cleanup/data_store/exp_info.py

Propchange: branches/frame_order_cleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Sep 26 19:36:39 2014
@@ -1 +1 @@
-/trunk:1-26017,26043-26070
+/trunk:1-26017,26043-26072

Modified: branches/frame_order_cleanup/data_store/exp_info.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/data_store/exp_info.py?rev=26082&r1=26081&r2=26082&view=diff
==============================================================================
--- branches/frame_order_cleanup/data_store/exp_info.py (original)
+++ branches/frame_order_cleanup/data_store/exp_info.py Fri Sep 26 19:36:39 
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.
 
@@ -258,7 +297,7 @@
         software.desc = "Software program used in the analysis"
 
         # Set the attributes.
-        software.name = name
+        software.software_name = name
         software.url = url
         software.version = version
         software.vendor_name = vendor_name




Related Messages


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