Author: bugman Date: Sat May 5 21:58:00 2012 New Revision: 16006 URL: http://svn.gna.org/viewcvs/relax?rev=16006&view=rev Log: The user function backend and title values are now enforced. If these are not set, a RelaxError is thrown. This should avoid fatal coding accidents. Modified: branches/uf_redesign/user_functions/__init__.py branches/uf_redesign/user_functions/data.py Modified: branches/uf_redesign/user_functions/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/__init__.py?rev=16006&r1=16005&r2=16006&view=diff ============================================================================== --- branches/uf_redesign/user_functions/__init__.py (original) +++ branches/uf_redesign/user_functions/__init__.py Sat May 5 21:58:00 2012 @@ -42,3 +42,9 @@ # Import all the modules to set up the data. import user_functions.bmrb import user_functions.pipe + +# Import the data structure. +from user_functions.data import Uf_info; uf_info = Uf_info() + +# Check the validity of the data. +uf_info.validate() Modified: branches/uf_redesign/user_functions/data.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/data.py?rev=16006&r1=16005&r2=16006&view=diff ============================================================================== --- branches/uf_redesign/user_functions/data.py (original) +++ branches/uf_redesign/user_functions/data.py Sat May 5 21:58:00 2012 @@ -25,6 +25,7 @@ # Python module imports. from re import search +from relax_errors import RelaxError from string import split # relax module imports. @@ -147,3 +148,17 @@ # Loop over the user functions. for i in range(len(self._uf_names)): yield self._uf_names[i], self._uf[i] + + + def validate(self): + """Validate that all of the user functions have been correctly set up.""" + + # Loop over the user functions. + for name, uf in self.uf_loop(): + # Check the title. + if uf.title == None: + raise RelaxError("The title of the %s user function has not been specified." % name) + + # Check the backend. + if uf.backend == None: + raise RelaxError("The back end of the %s user function has not been specified." % name)