mailr15947 - /branches/uf_redesign/prompt/objects.py


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

Header


Content

Posted by edward on May 04, 2012 - 09:34:
Author: bugman
Date: Fri May  4 09:34:23 2012
New Revision: 15947

URL: http://svn.gna.org/viewcvs/relax?rev=15947&view=rev
Log:
The prompt intro strings are now created for the auto-generated user 
functions.


Modified:
    branches/uf_redesign/prompt/objects.py

Modified: branches/uf_redesign/prompt/objects.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/objects.py?rev=15947&r1=15946&r2=15947&view=diff
==============================================================================
--- branches/uf_redesign/prompt/objects.py (original)
+++ branches/uf_redesign/prompt/objects.py Fri May  4 09:34:23 2012
@@ -68,26 +68,42 @@
     def __call__(self, *args, **kwds):
         """Make the user function executable."""
 
-        # Generate a list of allowed kargs.
-        if not hasattr(self, '_karg_names'):
-            self._karg_names = []
-            for i in range(len(self._kargs)):
-                self._karg_names.append(self._kargs[i]['name'])
-
         # Check the keyword args.
-        for name in kwds.keys():
+        keys = kwds.keys()
+        for name in keys:
             # Unknown keyword.
             if name not in self._karg_names:
                 raise RelaxError("The keyword argument '%s' is unknown." % 
name)
 
+        # Set the argument defaults.
+        values = []
+        for i in range(self._karg_num):
+            # The user supplied value.
+            if self._karg_names[i] in keys:
+                values.append(kwds[self._karg_names[i]])
+
+            # The default.
+            else:
+                values.append(self._karg_default[i])
+
         # Function intro text.
         if status.prompt_intro:
-            text = status.ps3 + "frame_order.cone_pdb("
-            text = text + "size=" + repr(size)
-            text = text + ", inc=" + repr(inc)
-            text = text + ", file=" + repr(file)
-            text = text + ", dir=" + repr(dir)
-            text = text + ", force=" + repr(force) + ")"
+            # The prompt and user function name.
+            text = "%s%s(" % (status.ps3, self._name)
+
+            # The keyword args.
+            for i in range(len(self._kargs)):
+                # Comma separation.
+                if i >= 1:
+                    text += ", "
+
+                # Add the arg.
+                text += "%s=%s" % (self._kargs[i]['name'], repr(values[i]))
+
+            # The end.
+            text += ")"
+
+            # Print out.
             print(text)
 
 
@@ -109,6 +125,14 @@
         # Check the args.
         if title == None:
             raise RelaxError("The title must be given.")
+
+        # Generate fixed keyword argument data structures (for faster 
execution).
+        self._karg_num = len(self._kargs)
+        self._karg_names = []
+        self._karg_default = []
+        for i in range(self._karg_num):
+            self._karg_names.append(self._kargs[i]['name'])
+            self._karg_default.append(self._kargs[i]['default'])
 
         # Build the user function documentation.
         self._build_doc()




Related Messages


Powered by MHonArc, Updated Fri May 04 10:00:01 2012