mailr16373 - /branches/uf_redesign/prompt/interpreter.py


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

Header


Content

Posted by edward on May 22, 2012 - 12:19:
Author: bugman
Date: Tue May 22 12:19:14 2012
New Revision: 16373

URL: http://svn.gna.org/viewcvs/relax?rev=16373&view=rev
Log:
Created a special private method for the prompt/script UIs for executing user 
functions.

This self._execute_uf() method will be used for the sharing of scripts in the 
system and GUI tests.


Modified:
    branches/uf_redesign/prompt/interpreter.py

Modified: branches/uf_redesign/prompt/interpreter.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/interpreter.py?rev=16373&r1=16372&r2=16373&view=diff
==============================================================================
--- branches/uf_redesign/prompt/interpreter.py (original)
+++ branches/uf_redesign/prompt/interpreter.py Tue May 22 12:19:14 2012
@@ -101,6 +101,33 @@
         self._locals = self._setup()
 
 
+    def _execute_uf(self, uf_name=None, *args, **kargs):
+        """Private method for executing the given user function.
+
+        @keyword uf_name:   The name of the user function.
+        @type uf_name:      str
+        """
+
+        # Split up the name.
+        if search('\.', uf_name):
+            class_name, uf_name = split(uf_name, '.')
+        else:
+            class_name = None
+
+        # Get the class object.
+        if class_name:
+            class_obj = self._locals[class_name]
+
+        # Get the user function.
+        if class_name:
+            uf = getattr(class_obj, uf_name)
+        else:
+            uf = self._locals[uf_name]
+
+        # Call the user function.
+        uf(*args, **kargs)
+
+
     def _setup(self):
         """Set up all the interpreter objects.
 




Related Messages


Powered by MHonArc, Updated Tue May 22 12:40:02 2012