mailr15939 - in /branches/uf_redesign/prompt: interpreter.py objects.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:35:
Author: bugman
Date: Thu May  3 22:35:24 2012
New Revision: 15939

URL: http://svn.gna.org/viewcvs/relax?rev=15939&view=rev
Log:
Primitive auto-generation of the user functions.

This simply creates an object for the user function, but it is not callable 
yet or uses any of the
user function data.


Modified:
    branches/uf_redesign/prompt/interpreter.py
    branches/uf_redesign/prompt/objects.py

Modified: branches/uf_redesign/prompt/interpreter.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/interpreter.py?rev=15939&r1=15938&r2=15939&view=diff
==============================================================================
--- branches/uf_redesign/prompt/interpreter.py (original)
+++ branches/uf_redesign/prompt/interpreter.py Thu May  3 22:35:24 2012
@@ -36,6 +36,7 @@
     import readline
 if dep_check.runpy_module:
     import runpy
+from string import split
 import sys
 
 # Python modules accessible on the command prompt.
@@ -105,7 +106,7 @@
 from user_functions.data import Uf_info; uf_info = Uf_info()
 
 # Auto-generation objects.
-from prompt.objects import Class_container
+from prompt.objects import Class_container, Uf_object
 
 
 class Interpreter:
@@ -162,6 +163,21 @@
 
             # Add the object to the local namespace.
             self._locals[name] = obj
+
+        # Then generate the user functions.
+        for name, data in uf_info.uf_loop():
+            # Split up the name.
+            class_name, uf_name = split(name, '.')
+
+            # Generate a new container.
+            obj = Uf_object(name)
+
+            # Get the class object.
+            class_obj = self._locals[class_name]
+
+            # Add the object to the user function class.
+            setattr(class_obj, uf_name, obj)
+
 
 
     def _setup(self):

Modified: branches/uf_redesign/prompt/objects.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/objects.py?rev=15939&r1=15938&r2=15939&view=diff
==============================================================================
--- branches/uf_redesign/prompt/objects.py (original)
+++ branches/uf_redesign/prompt/objects.py Thu May  3 22:35:24 2012
@@ -57,3 +57,18 @@
 
         # Return a description.
         return "<The %s user function class object>" % self._name
+
+
+
+class Uf_object(object):
+    """The object for auto-generating the user functions."""
+
+    def __init__(self, name):
+        """Set up the object.
+
+        @param name:    The name of the user function.
+        @type name:     str
+        """
+
+        # Store the args.
+        self._name = name




Related Messages


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