mailr6535 - /1.3/data/mol_res_spin.py


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

Header


Content

Posted by edward on June 28, 2008 - 22:43:
Author: bugman
Date: Sat Jun 28 22:43:47 2008
New Revision: 6535

URL: http://svn.gna.org/viewcvs/relax?rev=6535&view=rev
Log:
Created the SpinList.from_xml() method.


Modified:
    1.3/data/mol_res_spin.py

Modified: 1.3/data/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/data/mol_res_spin.py?rev=6535&r1=6534&r2=6535&view=diff
==============================================================================
--- 1.3/data/mol_res_spin.py (original)
+++ 1.3/data/mol_res_spin.py Sat Jun 28 22:43:47 2008
@@ -31,7 +31,7 @@
 import data
 from prototype import Prototype
 from relax_errors import RelaxError, RelaxFromXMLNotEmptyError
-from relax_xml import fill_object_contents
+from relax_xml import fill_object_contents, xml_to_object
 import specific_fns
 
 
@@ -183,6 +183,28 @@
         return False
 
 
+    def from_xml(self, spin_nodes):
+        """Recreate a spin list data structure from the XML spin nodes.
+
+        @param spin_nodes:  The spin XML nodes.
+        @type spin_nodes:   xml.dom.minicompat.NodeList instance
+        """
+
+        # Test if empty.
+        if not self.is_empty():
+            raise RelaxFromXMLNotEmptyError, self.__class__.__name__
+
+        # Loop over the spins.
+        for spin_node in spin_nodes:
+            # Get the spin details and add the spin to the SpinList 
structure.
+            name = spin_node.getAttribute('name')
+            num = spin_node.getAttribute('num')
+            self.add_item(spin_name=name, spin_num=num)
+
+            # Recreate the current spin container.
+            xml_to_object(spin_node, self[-1])
+
+
     def xml_create_element(self, doc, element):
         """Create XML elements for each spin.
 




Related Messages


Powered by MHonArc, Updated Sat Jun 28 23:00:21 2008