Ready for mentors
[cgmail.git] / cGmail / lib / storagehandler.py
blob015f663be85ed0857885c2334706fa21b2d83058
2 # Copyright (C) 2007 Marco Ferragina <marco.ferragina@gmail.com>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 class StorageHandler:
19 def readline(self):
20 """
21 Must return a line for each call. It must return a "not line"
22 when and only when no lines remains.
23 example:
24 line = obj.readline()
25 if not line:
26 print "not line"
27 not line must be printed only at the end of file
28 """
29 raise NotImplementedError()
31 def write(self, data):
32 """
33 write the data into the storage
34 """
35 raise NotImplementedError()
37 def get_new_writer(self):
38 """
39 Return a new writer object. This object must have the write method
40 (must be a StorageHandler). Before return the object this method
41 must initialize the Storage with empty data
42 """
43 raise NotImplementedError()
45 def close(self):
46 """
47 Finalize the storage. It execute the real writing or
48 close the file for a file storage handler
49 """
50 raise NotImplementedError()