]> code.delx.au - offlineimap/blob - head/offlineimap/repository/LocalStatus.py
/head: changeset 28
[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; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 from Base import BaseRepository
20 from imapsync import folder
21 import os
22
23 class LocalStatusRepository(BaseRepository):
24 def __init__(self, directory):
25 self.directory = directory
26 self.folders = None
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(\
45 self.getfolderfilename(folder)))
46 return retval
47
48 def getfolder(self, foldername):
49 return folder.LocalStatus.LocalStatusFolder(self.getfolderfilename(foldername))
50
51
52
53