Author: bugman Date: Wed Sep 4 17:47:45 2013 New Revision: 20807 URL: http://svn.gna.org/viewcvs/relax?rev=20807&view=rev Log: Created the pipe_control.spectrum.test_spectrum_id() function for checking if a spectrum ID exists. Modified: trunk/pipe_control/spectrum.py Modified: trunk/pipe_control/spectrum.py URL: http://svn.gna.org/viewcvs/relax/trunk/pipe_control/spectrum.py?rev=20807&r1=20806&r2=20807&view=diff ============================================================================== --- trunk/pipe_control/spectrum.py (original) +++ trunk/pipe_control/spectrum.py Wed Sep 4 17:47:45 2013 @@ -726,3 +726,19 @@ # Return the list. return repl + + +def test_spectrum_id(id): + """Test that the give spectrum ID exists. + + @param id: The spectrum ID to check for. + @type id: str + """ + + # Check that the spectrum ID structure exists. + if not hasattr(cdp, 'spectrum_ids'): + raise RelaxNoSpectraError(id) + + # Test if the spectrum ID exists. + if spectrum_id not in cdp.spectrum_ids: + raise RelaxNoSpectraError(id)