]> code.delx.au - offlineimap/blob - offlineimap/head/offlineimap/repository/LocalStatus.py
/offlineimap/head: changeset 360
[offlineimap] / offlineimap / head / offlineimap / repository / LocalStatus.py
1 # Local status cache repository support
2 # Copyright (C) 2002 John Goerzen
3 # <jgoerzen@complete.org>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
8 #
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.
13 #
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18 from Base import BaseRepository
19 from offlineimap import folder
20 import os
21
22 class LocalStatusRepository(BaseRepository):
23 def __init__(self, directory, accountname):
24 self.directory = directory
25 self.folders = None
26 self.accountname = accountname
27
28 def getsep(self):
29 return '.'
30
31 def getfolderfilename(self, foldername):
32 return os.path.join(self.directory, foldername)
33
34 def makefolder(self, foldername):
35 # "touch" the file.
36 file = open(self.getfolderfilename(foldername), "ab")
37 file.close()
38 # Invalidate the cache.
39 self.folders = None
40
41 def getfolders(self):
42 retval = []
43 for folder in os.listdir(self.directory):
44 retval.append(folder.LocalStatus.LocalStatusFolder(self.directory,
45 folder, self, self.accountname))
46 return retval
47
48 def getfolder(self, foldername):
49 return folder.LocalStatus.LocalStatusFolder(self.directory, foldername,
50 self, self.accountname)
51
52
53
54
55