mailr15950 - /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 - 10:02:
Author: bugman
Date: Fri May  4 10:02:36 2012
New Revision: 15950

URL: http://svn.gna.org/viewcvs/relax?rev=15950&view=rev
Log:
The auto-generated prompt user function front ends now convert arguments to 
keyword arguments.

This is important as a keyword arg can be supplied without the keyword in 
Python!


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=15950&r1=15949&r2=15950&view=diff
==============================================================================
--- branches/uf_redesign/prompt/objects.py (original)
+++ branches/uf_redesign/prompt/objects.py Fri May  4 10:02:36 2012
@@ -75,8 +75,20 @@
             if name not in self._karg_names:
                 raise RelaxError("The keyword argument '%s' is unknown." % 
name)
 
+        # Convert the args to keyword args if needed.
+        num_args = len(args)
+        if num_args:
+            for i in range(num_args):
+                # Check if the keyword is already assigned.
+                if self._kargs[i]['name'] in keys:
+                    raise RelaxError("The argument '%s' and the keyword 
argument '%s' cannot both be supplied." % (args[i], self._kargs[i]['name']))
+
+                # Add the arg as a keyword arg.
+                kwds[self._kargs[i]['name']] = args[i]
+
         # Set the argument defaults.
         values = []
+        keys = kwds.keys()
         for i in range(self._karg_num):
             # The user supplied value.
             if self._kargs[i]['name'] in keys:




Related Messages


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