mailr13602 - in /branches/gui_testing: generic_fns/pipes.py gui/user_functions/__init__.py observer.py status.py


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

Header


Content

Posted by edward on July 13, 2011 - 19:29:
Author: bugman
Date: Wed Jul 13 19:29:13 2011
New Revision: 13602

URL: http://svn.gna.org/viewcvs/relax?rev=13602&view=rev
Log:
Shifted the observer class into the status module.

It will soon only be used in this module to group all observers under 
status.observers.


Removed:
    branches/gui_testing/observer.py
Modified:
    branches/gui_testing/generic_fns/pipes.py
    branches/gui_testing/gui/user_functions/__init__.py
    branches/gui_testing/status.py

Modified: branches/gui_testing/generic_fns/pipes.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/generic_fns/pipes.py?rev=13602&r1=13601&r2=13602&view=diff
==============================================================================
--- branches/gui_testing/generic_fns/pipes.py (original)
+++ branches/gui_testing/generic_fns/pipes.py Wed Jul 13 19:29:13 2011
@@ -30,7 +30,6 @@
 # relax module imports.
 from data import Relax_data_store; ds = Relax_data_store()
 from dep_check import C_module_exp_fn, scipy_module
-from observer import Observer
 from relax_errors import RelaxError, RelaxNoPipeError, RelaxPipeError
 from status import Status; status = Status()
 

Modified: branches/gui_testing/gui/user_functions/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/user_functions/__init__.py?rev=13602&r1=13601&r2=13602&view=diff
==============================================================================
--- branches/gui_testing/gui/user_functions/__init__.py (original)
+++ branches/gui_testing/gui/user_functions/__init__.py Wed Jul 13 19:29:13 
2011
@@ -24,7 +24,7 @@
 """User function GUI elements."""
 
 # relax module imports.
-from observer import Observer
+from status import Observer
 from relax_errors import RelaxError
 
 # GUI module imports.

Removed: branches/gui_testing/observer.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/observer.py?rev=13601&view=auto
==============================================================================
--- branches/gui_testing/observer.py (original)
+++ branches/gui_testing/observer.py (removed)
@@ -1,77 +1,0 @@
-###############################################################################
-#                                                                            
 #
-# Copyright (C) 2011 Edward d'Auvergne                                       
 #
-#                                                                            
 #
-# This file is part of the program relax.                                    
 #
-#                                                                            
 #
-# relax is free software; you can redistribute it and/or modify              
 #
-# it under the terms of the GNU General Public License as published by       
 #
-# the Free Software Foundation; either version 2 of the License, or          
 #
-# (at your option) any later version.                                        
 #
-#                                                                            
 #
-# relax is distributed in the hope that it will be useful,                   
 #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of             
 #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
 #
-# GNU General Public License for more details.                               
 #
-#                                                                            
 #
-# You should have received a copy of the GNU General Public License          
 #
-# along with relax; if not, write to the Free Software                       
 #
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
 #
-#                                                                            
 #
-###############################################################################
-
-# Module docstring.
-"""Module implementing the observer design pattern base class."""
-
-# relax module imports.
-from relax_errors import RelaxError
-
-
-class Observer(object):
-    """The observer design pattern base class."""
-
-    def __init__(self):
-        """Set up the object."""
-
-        # The dictionary of callback methods.
-        self._callback = {}
-
-
-    def notify_observers(self):
-        """Notify all observers of the state change."""
-
-        # Loop over the callback methods and execute them.
-        for key in self._callback.keys():
-            self._callback[key]()
-
-
-    def register_observer(self, key, method):
-        """Register a method to be called when the state changes.
-
-        @param key:     The key to identify the observer's method.
-        @type key:      str
-        @param method:  The observer's method to be called after a state 
change.
-        @type method:   method
-        """
-
-        # Already exists.
-        if key in self._callback.keys():
-            raise RelaxError("The observer '%s' already exists." % key)
-
-        # Add the method to the dictionary of callbacks.
-        self._callback[key] = method
-
-
-    def unregister_observer(self, key):
-        """Unregister the method corresponding to the key.
-
-        @param key:     The key to identify the observer's method.
-        @type key:      str
-        """
-
-        # Does not exist.
-        if key not in self._callback.keys():
-            raise RelaxError("The key '%s' does not exist." % key)
-
-        # Remove the method from the dictionary of callbacks.
-        self._callback.pop(key)

Modified: branches/gui_testing/status.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/status.py?rev=13602&r1=13601&r2=13602&view=diff
==============================================================================
--- branches/gui_testing/status.py (original)
+++ branches/gui_testing/status.py Wed Jul 13 19:29:13 2011
@@ -29,7 +29,7 @@
 from threading import Lock
 
 # relax module imports.
-from observer import Observer
+from relax_errors import RelaxError
 
 
 class Status(object):
@@ -236,3 +236,54 @@
 
         # Release the real lock.
         return self._lock.release()
+
+
+
+class Observer(object):
+    """The observer design pattern base class."""
+
+    def __init__(self):
+        """Set up the object."""
+
+        # The dictionary of callback methods.
+        self._callback = {}
+
+
+    def notify_observers(self):
+        """Notify all observers of the state change."""
+
+        # Loop over the callback methods and execute them.
+        for key in self._callback.keys():
+            self._callback[key]()
+
+
+    def register_observer(self, key, method):
+        """Register a method to be called when the state changes.
+
+        @param key:     The key to identify the observer's method.
+        @type key:      str
+        @param method:  The observer's method to be called after a state 
change.
+        @type method:   method
+        """
+
+        # Already exists.
+        if key in self._callback.keys():
+            raise RelaxError("The observer '%s' already exists." % key)
+
+        # Add the method to the dictionary of callbacks.
+        self._callback[key] = method
+
+
+    def unregister_observer(self, key):
+        """Unregister the method corresponding to the key.
+
+        @param key:     The key to identify the observer's method.
+        @type key:      str
+        """
+
+        # Does not exist.
+        if key not in self._callback.keys():
+            raise RelaxError("The key '%s' does not exist." % key)
+
+        # Remove the method from the dictionary of callbacks.
+        self._callback.pop(key)




Related Messages


Powered by MHonArc, Updated Wed Jul 13 20:00:01 2011