mailr25647 - /tags/3.3.0/prompt/interpreter.py


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

Header


Content

Posted by edward on September 04, 2014 - 17:58:
Author: bugman
Date: Thu Sep  4 17:58:37 2014
New Revision: 25647

URL: http://svn.gna.org/viewcvs/relax?rev=25647&view=rev
Log:
Ported r25643 from trunk to provide for catching of old user function calls.

The command used was:
svn merge -r25642:25643 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk .

.....
  r25643 | bugman | 2014-09-04 17:44:58 +0200 (Thu, 04 Sep 2014) | 10 lines
  Changed paths:
     M /trunk/prompt/interpreter.py
  
  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:
    tags/3.3.0/prompt/interpreter.py

Modified: tags/3.3.0/prompt/interpreter.py
URL: 
http://svn.gna.org/viewcvs/relax/tags/3.3.0/prompt/interpreter.py?rev=25647&r1=25646&r2=25647&view=diff
==============================================================================
--- tags/3.3.0/prompt/interpreter.py    (original)
+++ tags/3.3.0/prompt/interpreter.py    Thu Sep  4 17:58:37 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.




Related Messages


Powered by MHonArc, Updated Thu Sep 04 18:20:03 2014