mailr25646 - /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:56:
Author: bugman
Date: Thu Sep  4 17:56:53 2014
New Revision: 25646

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

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

.....
  r25642 | bugman | 2014-09-04 17:18:08 +0200 (Thu, 04 Sep 2014) | 10 lines
  Changed paths:
     M /trunk/prompt/interpreter.py
  
  The prompt UI now uses the user_functions.uf_translation_table dictionary.
  
  The modified runcode() function will now check if the command typed by the 
user is a function or
  method call and then will raise a RelaxError if the command name is in the
  user_functions.uf_translation_table dictionary, telling the user that the 
user function has been
  renamed to the new name in the translation table.
  
  This appears to have no effect in the script UI however.
.....


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=25646&r1=25645&r2=25646&view=diff
==============================================================================
--- tags/3.3.0/prompt/interpreter.py    (original)
+++ tags/3.3.0/prompt/interpreter.py    Thu Sep  4 17:56:53 2014
@@ -48,6 +48,7 @@
 from prompt.uf_objects import Class_container, Uf_object
 from lib.errors import AllRelaxErrors, RelaxError
 from status import Status; status = Status()
+from user_functions import uf_translation_table
 from user_functions.data import Uf_info; uf_info = Uf_info()
 
 
@@ -579,13 +580,27 @@
     @type code:     str
     """
 
+    # Safely run the code.
     try:
+        # Catch old user function calls or class method calls.
+        if code.co_code in ['e\x00\x00\x83\x00\x00Fd\x00\x00S', 
'e\x00\x00j\x01\x00\x83\x00\x00Fd\x00\x00S']:
+            # Is this an old user function?
+            if len(code.co_names) and code.co_names[0] in 
uf_translation_table:
+                raise RelaxError("The user function '%s' has been renamed to 
'%s'." % (code.co_names[0], uf_translation_table[code.co_names[0]]))
+
+        # Execute the code.
         exec(code, self.locals)
+
+    # Allow the system to exit.
     except SystemExit:
         raise
+
+    # Handle RelaxErrors nicely.
     except AllRelaxErrors:
         instance = sys.exc_info()[1]
         self.write(instance.__str__())
         self.write("\n")
+
+    # Everything else.
     except:
         self.showtraceback()




Related Messages


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