1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """
23 To handle ETL signal.
24
25 Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
26 GNU General Public License.
27
28 """
30 """
31 ETL Signal.
32 Each component can send signals. Trigger Transitions can listen to these signals.
33 Signals are automatically generated:
34 - start : When the component starts.
35 - start_input : At the first row received by the component.
36 - start_output : At the first row sent by the component.
37 - no_input : At the end of the process, when no data is received.
38 - stop : When the component is paused.
39 - continue : When the component restarts after a pause.
40 - end : When the component finishes its process.
41 - error : When the component gives error.
42 """
45
46 - def signal(self, signal, signal_data=None):
47 for fnct, data, key in self.__connects.get(signal, []):
48 fnct(key, signal_data, *data)
49
50
52 self.__connects.setdefault(signal, [])
53 if (fnct, data, key) not in self.__connects[signal]:
54 self.__connects[signal].append((fnct, data, key))
55
56
58 if not signal:
59 signal = self.__connects.keys()
60 else:
61 signal = [signal]
62 for sig in signal:
63 i = 0
64 while i < len(self.__connects[sig]):
65 if self.__connects[sig][i][2] == key:
66 del self.__connects[sig][i]
67 else:
68 i += 1
69