mailr9540 - /1.3/data/relax_xml.py


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

Header


Content

Posted by edward on September 18, 2009 - 19:15:
Author: bugman
Date: Fri Sep 18 19:15:40 2009
New Revision: 9540

URL: http://svn.gna.org/viewcvs/relax?rev=9540&view=rev
Log:
Try again:  Added the blacklist arg to xml_to_object().


Modified:
    1.3/data/relax_xml.py

Modified: 1.3/data/relax_xml.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/data/relax_xml.py?rev=9540&r1=9539&r2=9540&view=diff
==============================================================================
--- 1.3/data/relax_xml.py (original)
+++ 1.3/data/relax_xml.py Fri Sep 18 19:15:40 2009
@@ -39,9 +39,9 @@
     @type doc:          xml.dom.minidom.Document instance
     @param elem:        The element to add all python objects to.
     @type elem:         XML element object
-    @param object:      The python class instance containing the objects to 
add.
+    @keyword object:    The python class instance containing the objects to 
add.
     @type object:       instance
-    @param blacklist:   A list of object names to exclude.
+    @keyword blacklist: A list of object names to exclude.
     @type blacklist:    list of str
     """
 
@@ -89,16 +89,18 @@
     return eval(val)
 
 
-def xml_to_object(elem, base_object=None, set_fn=None):
+def xml_to_object(elem, base_object=None, set_fn=None, blacklist=None):
     """Convert the XML elements into python objects, and place these into 
the base object.
 
-    @param elem:        The element to extract all python objects from.
-    @type elem:         xml.dom.minidom.Element instance
-    @param base_object: The python class instance to place the objects into.
-    @type  base_bject:  instance
-    @param set_fn:      A function used to replace setattr for placing the 
object into the base
-                        object.
-    @type set_fn:       function
+    @param elem:            The element to extract all python objects from.
+    @type elem:             xml.dom.minidom.Element instance
+    @keyword base_object:   The python class instance to place the objects 
into.
+    @type  base_bject:      instance
+    @keyword set_fn:        A function used to replace setattr for placing 
the object into the base
+                            object.
+    @type set_fn:           function
+    @keyword blacklist:     A list of object names to exclude.
+    @type blacklist:        list of str
     """
 
     # Loop over the nodes of the element
@@ -109,6 +111,10 @@
 
         # The name of the python object to recreate.
         name = str(node.localName)
+
+        # Skip blacklisted objects.
+        if name in blacklist:
+            continue
 
         # IEEE-754 floats (for full precision restoration).
         ieee_array = node.getAttribute('ieee_754_byte_array')




Related Messages


Powered by MHonArc, Updated Fri Sep 18 19:20:03 2009