diff src/tools/misc.py @ 590:56531f9e9ac7

Fix pep8 support in src/tools.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:35 +0100
parents beaf6bec2fcd
children 84a6e83157c2
line wrap: on
line diff
--- a/src/tools/misc.py	Fri Jan 18 17:55:35 2013 +0100
+++ b/src/tools/misc.py	Fri Jan 18 17:55:35 2013 +0100
@@ -19,34 +19,38 @@
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
-from logging import debug, info, error
+"""Misc usefull classes"""
 
-"""Misc usefull classes"""
 
 class TriggerException(Exception):
     pass
 
+
 class SkipOtherTriggers(Exception):
     """ Exception to raise if normal behaviour must be followed instead of
         followind triggers list """
     pass
 
+
 class TriggerManager(object):
-    """This class manage triggers: code which interact to change de behaviour of SàT"""
+    """This class manage triggers: code which interact to change de behaviour
+    of SàT"""
 
     def __init__(self):
-        self.__triggers={}
+        self.__triggers = {}
 
     def add(self, point_name, callback, priority=0):
         """Add a trigger to a point
         @param point_name: name of the point when the trigger should be run
         @param callback: method to call at the trigger point
-        @param priority: callback will be called in priority order, biggest first
+        @param priority: callback will be called in priority order, biggest
+        first
         """
-        if not self.__triggers.has_key(point_name):
-            self.__triggers[point_name]=[]
+        if point_name not in self.__triggers:
+            self.__triggers[point_name] = []
         self.__triggers[point_name].append((priority, callback))
-        self.__triggers[point_name].sort(key=lambda trigger_tuple: trigger_tuple[0], reverse=True)
+        self.__triggers[point_name].sort(key=lambda trigger_tuple:
+                                         trigger_tuple[0], reverse=True)
 
     def remove(self, point_name, callback):
         """Remove a trigger from a point
@@ -63,7 +67,7 @@
         All the trigger for that point will be run
         @param point_name: name of the trigger point
         @return: True if the action must be continued, False else"""
-        if not self.__triggers.has_key(point_name):
+        if point_name not in self.__triggers:
             return True
 
         for priority,trigger in self.__triggers[point_name]:
@@ -73,4 +77,3 @@
             except SkipOtherTriggers:
                 break
         return True
-