mailr14518 - /1.3/gui/interpreter.py


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

Header


Content

Posted by edward on August 30, 2011 - 11:58:
Author: bugman
Date: Tue Aug 30 11:58:00 2011
New Revision: 14518

URL: http://svn.gna.org/viewcvs/relax?rev=14518&view=rev
Log:
Added the _get_uf() method to the GUI interpreter object for abstracting the 
code.


Modified:
    1.3/gui/interpreter.py

Modified: 1.3/gui/interpreter.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/gui/interpreter.py?rev=14518&r1=14517&r2=14518&view=diff
==============================================================================
--- 1.3/gui/interpreter.py (original)
+++ 1.3/gui/interpreter.py Tue Aug 30 11:58:00 2011
@@ -66,6 +66,34 @@
         self._exit = False
 
 
+    def _get_uf(self, uf):
+        """Return the user function object corresponding to the given string.
+
+        @param uf:  The name of the user function.
+        @type uf:   str
+        @return:    The user function object.
+        @rtype:     func
+        """
+
+        # Handle the user function class.
+        if search('\.', uf):
+            # Split the user function.
+            uf_class, uf_fn = split(uf, '.')
+
+            # Get the user function class.
+            obj = getattr(self._interpreter, uf_class)
+
+            # Get the function.
+            fn = getattr(obj, uf_fn)
+
+        # Simple user function.
+        else:
+            fn = getattr(self._interpreter, uf)
+
+        # Return the user function.
+        return fn
+
+
     def empty(self):
         """Wrapper method for the Queue.empty() method."""
 
@@ -122,20 +150,8 @@
 
             # Execute the user function, catching errors.
             try:
-                # Handle the user function class.
-                if search('\.', uf):
-                    # Split the user function.
-                    uf_class, uf_fn = split(uf, '.')
-
-                    # Get the user function class.
-                    obj = getattr(self._interpreter, uf_class)
-
-                    # Get the function.
-                    fn = getattr(obj, uf_fn)
-
-                # Simple user function.
-                else:
-                    fn = getattr(self._interpreter, uf)
+                # Get the user function.
+                fn = self._get_uf(uf)
 
                 # Apply the user function.
                 apply(fn, args, kwds)




Related Messages


Powered by MHonArc, Updated Tue Aug 30 13:20:02 2011