code style reformatting using black
This commit is contained in:
parent
4127bcffd0
commit
744cb0c503
1 changed files with 21394 additions and 10488 deletions
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
from sat.core.i18n import _
|
||||
from sat.core.log import getLogger
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
|
||||
|
|
@ -30,6 +31,7 @@ class TriggerException(Exception):
|
|||
|
||||
class SkipOtherTriggers(Exception):
|
||||
""" Exception to raise if normal behaviour must be followed instead of following triggers list """
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -37,8 +39,8 @@ class TriggerManager(object):
|
|||
"""This class manage triggers: code which interact to change the behaviour of SàT"""
|
||||
|
||||
try: # FIXME: to be removed when a better solution is found
|
||||
MIN_PRIORITY = float('-inf')
|
||||
MAX_PRIORITY = float('+inf')
|
||||
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
|
||||
|
|
@ -57,14 +59,20 @@ class TriggerManager(object):
|
|||
"""
|
||||
if point_name not in self.__triggers:
|
||||
self.__triggers[point_name] = []
|
||||
if priority != 0 and priority in [trigger_tuple[0] for trigger_tuple in self.__triggers[point_name]]:
|
||||
if priority != 0 and priority in [
|
||||
trigger_tuple[0] for trigger_tuple in self.__triggers[point_name]
|
||||
]:
|
||||
if priority in (self.MIN_PRIORITY, self.MAX_PRIORITY):
|
||||
log.warning(_(u"There is already a bound priority [%s]") % point_name)
|
||||
else:
|
||||
log.debug(_(u"There is already a trigger with the same priority [%s]") % point_name)
|
||||
log.debug(
|
||||
_(u"There is already a trigger with the same priority [%s]")
|
||||
% 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
|
||||
|
|
|
|||
Loading…
Reference in a new issue