Author: bugman Date: Tue Dec 11 15:47:47 2012 New Revision: 18108 URL: http://svn.gna.org/viewcvs/relax?rev=18108&view=rev Log: Spun out code from generic_fns.pipes.create() into the new check_type() function. This code will be reused in a new pipe user function. Modified: trunk/generic_fns/pipes.py Modified: trunk/generic_fns/pipes.py URL: http://svn.gna.org/viewcvs/relax/trunk/generic_fns/pipes.py?rev=18108&r1=18107&r2=18108&view=diff ============================================================================== --- trunk/generic_fns/pipes.py (original) +++ trunk/generic_fns/pipes.py Tue Dec 11 15:47:47 2012 @@ -162,6 +162,28 @@ @type switch: bool """ + # Tests for the pipe type. + check_type(pipe_type) + + # Acquire the pipe lock (data modifying function), and make sure it is finally released. + status.pipe_lock.acquire(sys._getframe().f_code.co_name) + try: + # Add the data pipe. + ds.add(pipe_name=pipe_name, pipe_type=pipe_type, bundle=bundle, switch=switch) + + # Release the lock. + finally: + status.pipe_lock.release(sys._getframe().f_code.co_name) + + +def check_type(pipe_type): + """Check the validity of the given data pipe type. + + @keyword pipe_type: The data pipe type to check. + @type pipe_type: str + @raises RelaxError: If the data pipe type is invalid or the required Python modules are missing. + """ + # Test if pipe_type is valid. if not pipe_type in VALID_TYPES: raise RelaxError("The data pipe type " + repr(pipe_type) + " is invalid and must be one of the strings in the list " + repr(VALID_TYPES) + ".") @@ -173,16 +195,6 @@ # Test that the scipy is installed for the frame order analysis. if pipe_type == 'frame order' and not scipy_module: raise RelaxError("The frame order analysis is not available. Please install the scipy Python package.") - - # Acquire the pipe lock (data modifying function), and make sure it is finally released. - status.pipe_lock.acquire(sys._getframe().f_code.co_name) - try: - # Add the data pipe. - ds.add(pipe_name=pipe_name, pipe_type=pipe_type, bundle=bundle, switch=switch) - - # Release the lock. - finally: - status.pipe_lock.release(sys._getframe().f_code.co_name) def cdp_name():