mailr9506 - /1.3/data/__init__.py


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

Header


Content

Posted by edward on September 10, 2009 - 20:04:
Author: bugman
Date: Thu Sep 10 20:04:05 2009
New Revision: 9506

URL: http://svn.gna.org/viewcvs/relax?rev=9506&view=rev
Log:
Created the relax data store is_empty() method.


Modified:
    1.3/data/__init__.py

Modified: 1.3/data/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/data/__init__.py?rev=9506&r1=9505&r2=9506&view=diff
==============================================================================
--- 1.3/data/__init__.py (original)
+++ 1.3/data/__init__.py Thu Sep 10 20:04:05 2009
@@ -166,6 +166,38 @@
         __builtin__.cdp = self[pipe_name]
 
 
+    def is_empty(self):
+        """Method for testing if the relax data store is empty.
+
+        @return:    True if the data store is empty, False otherwise.
+        @rtype:     bool
+        """
+
+        # No pipes should exist.
+        if not self.keys() == []:
+            return False
+
+        # An object has been added to the data store.
+        for name in dir(self):
+            # Skip the data store methods.
+            if name in list(self.__class__.__dict__.keys()):
+                continue
+
+            # Skip the dict methods.
+            if name in list(dict.__dict__.keys()):
+                continue
+
+            # Skip special objects.
+            if search("^__", name):
+                continue
+
+            # An object has been added.
+            return False
+
+        # The data store is empty.
+        return True
+
+
     def from_xml(self, file, dir=None, verbosity=1):
         """Parse a XML document representation of a data pipe, and load it 
into the relax data store.
 




Related Messages


Powered by MHonArc, Updated Fri Sep 11 10:20:04 2009