mailr16106 - /branches/uf_redesign/user_functions/objects.py


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

Header


Content

Posted by edward on May 08, 2012 - 16:47:
Author: bugman
Date: Tue May  8 16:47:23 2012
New Revision: 16106

URL: http://svn.gna.org/viewcvs/relax?rev=16106&view=rev
Log:
Added error checking to the Uf_container to eliminate typo coding mistakes.

This checks that a variable is not set twice (copy and paste error).


Modified:
    branches/uf_redesign/user_functions/objects.py

Modified: branches/uf_redesign/user_functions/objects.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/objects.py?rev=16106&r1=16105&r2=16106&view=diff
==============================================================================
--- branches/uf_redesign/user_functions/objects.py (original)
+++ branches/uf_redesign/user_functions/objects.py Tue May  8 16:47:23 2012
@@ -162,6 +162,20 @@
         # Test if the attribute that is trying to be set is modifiable.
         if not name in self.__mod_attr__:
             raise RelaxError("The object '%s' is not a modifiable 
attribute." % name)
+
+        # Check for duplicative modifications (to catch typo coding errors).
+        if name in ['title', 'title_short', 'backend', 'desc', 'additional', 
'prompt_examples', 'gui_icon']:
+            # No object set yet.
+            if not hasattr(self, name):
+                obj = None
+
+            # Get the current object.
+            else:
+                obj = getattr(self, name)
+
+            # Not None!
+            if obj != None:
+                raise RelaxError("The variable '%s' is already set to %s." % 
(name, repr(obj)))
 
         # Set the attribute normally.
         self.__dict__[name] = value




Related Messages


Powered by MHonArc, Updated Tue May 08 17:00:02 2012