Debian Codegraph @

gavo/user/useless.py

raw
1 """
2 Useless observers.
3
4 Well, maybe they aren't useless, but at least they are not intended for
5 "normal" use.
6 """
7
8 #c Copyright 2008-2025, the GAVO project <[email protected]>
9 #c
10 #c This program is free software, covered by the GNU GPL. See the
11 #c COPYING file in the source distribution.
12
13
14 from gavo.base import ObserverBase
15
16 class DelugeUI(ObserverBase):
17 """is an observer that just dumps all events.
18 """
19 def __init__(self, dispatcher):
20 ObserverBase.__init__(self, dispatcher)
21 for eventType in dispatcher.eventTypes:
22 dispatcher.subscribe(eventType,
23 lambda arg, eventType=eventType: self.dumpStuff(arg, eventType))
24
25 def dumpStuff(self, stuff, eventType):
26 print(eventType, stuff)
27
28
29 class NullUI(ObserverBase):
30 """is an observer that reports no events at all.
31 """
32 def __init__(self, dispatcher):
33 pass