mailr15931 - /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 03, 2012 - 22:05:
Author: bugman
Date: Thu May  3 22:05:39 2012
New Revision: 15931

URL: http://svn.gna.org/viewcvs/relax?rev=15931&view=rev
Log:
The interpreter now auto-generates the user function classes.


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=15931&r1=15930&r2=15931&view=diff
==============================================================================
--- branches/uf_redesign/prompt/interpreter.py (original)
+++ branches/uf_redesign/prompt/interpreter.py Thu May  3 22:05:39 2012
@@ -104,6 +104,9 @@
 # User function data structure.
 from user_functions.data import Uf_info; uf_info = Uf_info()
 
+# Auto-generation objects.
+from prompt.objects import Class_container
+
 
 class Interpreter:
     def __init__(self, show_script=True, quit=True, raise_relax_error=False):
@@ -144,6 +147,24 @@
 
         # Set up the interpreter objects.
         self._locals = self._setup()
+
+        # Auto-generate the user functions and classes.
+        self._auto_generate()
+
+
+    def _auto_generate(self):
+        """Build the user function objects from the user function data 
object information."""
+
+        # First generate the classes.
+        for name, data in uf_info.class_loop():
+            # Generate a new container.
+            obj = Class_container(name)
+
+            # Replace the docstring.
+            obj.__doc__ = data.title
+
+            # Add the object to the local namespace.
+            self._locals[name] = obj
 
 
     def _setup(self):




Related Messages


Powered by MHonArc, Updated Thu May 03 22:20:02 2012