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


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
[email protected]

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits

Reply via email to