Support for nested/partial event hook filters #252

Merged
blacklight merged 1 commits from 251-nested-filters-on-event-hooks into master 2023-04-26 01:55:28 +02:00

1 Commits

Author SHA1 Message Date
Fabio Manganiello 245472a4c5
Better event hooks filters.
- Support for nested attributes on event hook conditions. Things like
  these are now possible:

```
from platypush.event.hook import hook
from platypush.message.event.entities import EntityUpdateEvent

@hook(EntityUpdateEvent, entity={"external_id": "system:cpu"})
def on_cpu_update_event(event: EntityUpdateEvent, **_):
    print(event.args["entity"]["percent"])
```

- The scoring/regex extraction/partial string match logic in
  `_matches_argument` is actually only needed for
  `SpeechRecognizedEvent`. Other events don't need these features, and
  event hooks may be actually triggered unexpectedly in case of partial
  matches. Therefore, the "complex" `_matches_argument` has been moved
  as an override only for `SpeechRecognizedEvent`, and all the other
  events will perform simple key-value matching.
2023-04-26 01:45:58 +02:00