From: Sergi R. <sr...@ce...> - 2016-01-13 16:16:04
|
Although not critical, this hook (or a similar implementation) would allow specific applications to modify/bypass the event management if needed. I'm using it to implement event grouping in synoptics, Sergi Rubio On 01/13/2016 05:08 PM, sr...@ce... wrote: > From: Sergio Rubio Manrique <sr...@ce...> > > --- > lib/taurus/core/util/eventfilters.py | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/lib/taurus/core/util/eventfilters.py b/lib/taurus/core/util/eventfilters.py > index 8dc52a1..52eb0ba 100644 > --- a/lib/taurus/core/util/eventfilters.py > +++ b/lib/taurus/core/util/eventfilters.py > @@ -156,8 +156,7 @@ class RepeatedEventFilter(object): > self._lastValues[(s, t)] = new_value > return s, t, v > > - > -def filterEvent(evt_src=-1, evt_type=-1, evt_value=-1, filters=()): > +def filterEvent(evt_src=-1, evt_type=-1, evt_value=-1 ,filters=(), hook=None): > """The event is processed by each and all filters in strict order > unless one of them returns None (in which case the event is discarded) > > @@ -168,6 +167,8 @@ def filterEvent(evt_src=-1, evt_type=-1, evt_value=-1, filters=()): > either None (to discard the event) or the tuple (with > possibly transformed values) of > (evt_src, evt_type, evt_value) > + :param hook: a callable to be executed if the event passed all the filters; > + if None, then just returns the event > > :return: (None or tuple) The result of piping the event through the given > filters. > @@ -178,4 +179,8 @@ def filterEvent(evt_src=-1, evt_type=-1, evt_value=-1, filters=()): > evt = f(*evt) > if evt is None: > return None > - return evt > + > + if hook: > + return hook(*evt) > + else: > + return evt |