mailr26061 - in /trunk: lib/checks.py pipe_control/spectrometer.py


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

Header


Content

Posted by edward on September 26, 2014 - 15:17:
Author: bugman
Date: Fri Sep 26 15:17:39 2014
New Revision: 26061

URL: http://svn.gna.org/viewcvs/relax?rev=26061&view=rev
Log:
Changed the behaviour of the lib.checks.Check object again.

This time the registered function is stored rather than converted into a 
class instance method.
That way the check_*() function-like objects do not need to accept the unused 
'self' argument.


Modified:
    trunk/lib/checks.py
    trunk/pipe_control/spectrometer.py

Modified: trunk/lib/checks.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/checks.py?rev=26061&r1=26060&r2=26061&view=diff
==============================================================================
--- trunk/lib/checks.py (original)
+++ trunk/lib/checks.py Fri Sep 26 15:17:39 2014
@@ -24,7 +24,6 @@
 """Module for the Check class based on the strategy design pattern."""
 
 # Python module imports.
-from types import MethodType
 from warnings import warn
 
 # relax module imports.
@@ -36,14 +35,14 @@
     """Data checking class based on the U{strategy design 
pattern<https://en.wikipedia.org/wiki/Strategy_pattern>}."""
 
     def __init__(self, function):
-        """Convert the function argument into a class instance method.
+        """Store the function argument for use in the __call__() method.
 
-        @param function:    The function to convert into the self.checks 
class instance method which is called from the __call__ method.
+        @param function:    The function to store as self.checks which is 
called from the __call__() method.
         @type function:     function
         """
 
-        # Convert the function into a method of this class instance.
-        self.checks = MethodType(function, self, Check)
+        # Store the function.
+        self.checks = function
 
 
     def __call__(self, *args, **kargs):

Modified: trunk/pipe_control/spectrometer.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/spectrometer.py?rev=26061&r1=26060&r2=26061&view=diff
==============================================================================
--- trunk/pipe_control/spectrometer.py  (original)
+++ trunk/pipe_control/spectrometer.py  Fri Sep 26 15:17:39 2014
@@ -34,7 +34,7 @@
 from pipe_control import pipes
 
 
-def check_frequency_func(self, id=None):
+def check_frequency_func(id=None):
     """Check that the frequency for the given ID has been set.
 
     @keyword id:    The experiment ID string.
@@ -51,7 +51,7 @@
 check_frequency = Check(check_frequency_func)
 
 
-def check_spectrometer_setup_func(self):
+def check_spectrometer_setup_func():
     """Check that spectrometer frequencies have been set up.
 
     @return:    The initialised RelaxError object or nothing.




Related Messages


Powered by MHonArc, Updated Fri Sep 26 15:40:02 2014