mailr3877 - /1.3/generic_fns/pipes.py


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

Header


Content

Posted by edward on November 24, 2007 - 12:21:
Author: bugman
Date: Sat Nov 24 12:16:30 2007
New Revision: 3877

URL: http://svn.gna.org/viewcvs/relax?rev=3877&view=rev
Log:
Created the test() function for testing the existence of the current or given 
data pipe.


Modified:
    1.3/generic_fns/pipes.py

Modified: 1.3/generic_fns/pipes.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/pipes.py?rev=3877&r1=3876&r2=3877&view=diff
==============================================================================
--- 1.3/generic_fns/pipes.py (original)
+++ 1.3/generic_fns/pipes.py Sat Nov 24 12:16:30 2007
@@ -137,3 +137,22 @@
 
     # Switch the current data pipe.
     relax_data_store.current_pipe = pipe_name
+
+
+def test(pipe_name=None):
+    """Function for testing the existence of the current or supplied data 
pipe.
+
+    @param pipe_name:   The name of the data pipe to switch to.
+    @type pipe_name:    str
+    @return:            The answer to the question of whether the pipe 
exists.
+    @rtype:             Boolean
+    """
+
+    # No supplied data pipe and no current data pipe.
+    if pipe_name == None and current() == None:
+        raise RelaxNoPipeError
+
+    # Test if the data pipe exists.
+    if not relax_data_store.has_key(pipe_name):
+        raise RelaxNoPipeError, pipe_name
+




Related Messages


Powered by MHonArc, Updated Sat Nov 24 12:40:09 2007