Package etl :: Module transition
[hide private]
[frames] | no frames]

Source Code for Module etl.transition

 1  # -*- encoding: utf-8 -*- 
 2  ############################################################################## 
 3  # 
 4  #    ETL system- Extract Transfer Load system 
 5  #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved 
 6  #    $Id$ 
 7  # 
 8  #    This program is free software: you can redistribute it and/or modify 
 9  #    it under the terms of the GNU General Public License as published by 
10  #    the Free Software Foundation, either version 3 of the License, or 
11  #    (at your option) any later version. 
12  # 
13  #    This program is distributed in the hope that it will be useful, 
14  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  #    GNU General Public License for more details. 
17  # 
18  #    You should have received a copy of the GNU General Public License 
19  #    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
20  # 
21  ############################################################################## 
22  """  
23   ETL transition. 
24   
25   Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). 
26   GNU General Public License. 
27  """ 
28  from signal import signal 
29  import datetime 
30 -class transition(signal):
31 """ 32 Base class of ETL transition. 33 """
34 - def __init__(self, source, destination, channel_source='main', channel_destination='main', type='data', trigger=None):
35 super(transition, self).__init__() 36 self.type = type 37 self.trigger = trigger 38 self.source = source 39 self.destination = destination 40 self.channel_source = channel_source 41 self.channel_destination = channel_destination 42 self.destination.trans_in.append((channel_destination, self)) 43 self.source.trans_out.append((channel_source, self)) 44 self.status = 'open' # open,close # open : active, close : inactive
45
46 - def __str__(self):
47 return "<Transition source='%s' destination='%s' channel_source='%s' channel_destination='%s' type='%s' trigger='%s' status='%s'>" \ 48 %(self.source.name, self.destination.name, self.type, self.channel_source, self.channel_destination, self.trigger, self.status)
49
50 - def __copy__(self):
51 res = transition(self.source, self.destination, self.channel_source, self.channel_destination, self.type) 52 return res
53
54 - def copy(self):
55 return self.__copy__()
56
57 - def open(self):
58 self.status = 'open'
59
60 - def close(self):
61 self.status = 'close'
62
63 - def stop(self):
64 self.status = 'stop' 65 self.signal('stop')
66
67 - def end(self):
68 self.status = 'end' 69 self.signal('end', {'date': datetime.datetime.today()})
70
71 - def start(self):
72 self.status = 'start' 73 self.signal('start', {'date': datetime.datetime.today()})
74
75 - def pause(self):
76 self.status = 'pause' 77 self.signal('pause')
78
79 - def restart(self):
80 self.status = 'start' 81 self.signal('restart')
82