Author: bugman Date: Thu Sep 4 17:44:58 2014 New Revision: 25643 URL: http://svn.gna.org/viewcvs/relax?rev=25643&view=rev Log: Hack in the script UI for handling missing user functions due to it being renamed. This script UI requires a different solution as the prompt UI. The script is executed via the runpy Python module and there appears to be no clean way of catching each command before it is executed. So instead, prior to executing the script, the contents of the script are read and old user functions are searched for using re.search(). The old user function name has "(" appended to it in the search so that it is sure that it is a user function call. And the old function must have a space or newline character preceding it. Modified: trunk/prompt/interpreter.py Modified: trunk/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/trunk/prompt/interpreter.py?rev=25643&r1=25642&r2=25643&view=diff ============================================================================== --- trunk/prompt/interpreter.py (original) +++ trunk/prompt/interpreter.py Thu Sep 4 17:44:58 2014 @@ -341,6 +341,18 @@ if ext != '.py': raise RelaxError("The script must have the extension *.py.") + # Read the contents of the script for finding old user function calls, prepending a newline character so that old user functions on the first line of a script can be handled. + file = open(name) + text = '\n' + text += file.read() + file.close() + + # Parse the code in the module for old user function calls. + for old_uf in uf_translation_table: + # Find an old call. + if search('[ \\n]'+old_uf+'\(', text): + raise RelaxError("The user function '%s' has been renamed to '%s', please update your script." % (old_uf, uf_translation_table[old_uf])) + # Execute the module. try: # Reverse the system path so that the script path is first.