diff src/tools/misc.py @ 1347:ba41a81d14c2 frontends_multi_profiles

frontends (QuickApp), tools (TriggerManager): frontends can also use triggers + add those for sending and receiving a message
author souliane <souliane@mailoo.org>
date Tue, 03 Mar 2015 15:05:10 +0100
parents 301b342c697a
children
line wrap: on
line diff
--- a/src/tools/misc.py	Tue Mar 03 06:00:23 2015 +0100
+++ b/src/tools/misc.py	Tue Mar 03 15:05:10 2015 +0100
@@ -20,7 +20,6 @@
 """Misc usefull classes"""
 
 from sat.core.i18n import _
-import sys
 from sat.core.log import getLogger
 log = getLogger(__name__)
 
@@ -39,8 +38,13 @@
     """This class manage triggers: code which interact to change the behaviour
     of SàT"""
 
-    MIN_PRIORITY = float('-inf')
-    MAX_PRIORITY = float('+inf')
+    try:  # FIXME: to be removed when a better solution is found
+        MIN_PRIORITY = float('-inf')
+        MAX_PRIORITY = float('+inf')
+    except:  # XXX: Pyjamas will bug if you specify ValueError here
+        # Pyjamas uses the JS Float class
+        MIN_PRIORITY = Number.NEGATIVE_INFINITY
+        MAX_PRIORITY = Number.POSITIVE_INFINITY
 
     def __init__(self):
         self.__triggers = {}
@@ -81,7 +85,7 @@
         if point_name not in self.__triggers:
             return True
 
-        for priority,trigger in self.__triggers[point_name]:
+        for priority, trigger in self.__triggers[point_name]:
             try:
                 if not trigger(*args, **kwargs):
                     return False