]>
code.delx.au - offlineimap/blob - head/offlineimap/repository/LocalStatus.py
45ec047f6ac1b3ba21a9d988aa8712d7ebf4ef20
1 # Local status cache repository support
2 # Copyright (C) 2002 John Goerzen
3 # <jgoerzen@complete.org>
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.
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.
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
19 from Base
import BaseRepository
20 from offlineimap
import folder
23 class LocalStatusRepository(BaseRepository
):
24 def __init__(self
, reposname
, account
):
25 BaseRepository
.__init
__(self
, reposname
, account
)
26 self
.directory
= os
.path
.join(account
.getaccountmeta(), 'LocalStatus')
27 if not os
.path
.exists(self
.directory
):
28 os
.mkdir(self
.directory
, 0700)
34 def getfolderfilename(self
, foldername
):
35 foldername
= re
.sub('/\.$', '/dot', foldername
)
36 foldername
= re
.sub('^\.$', 'dot', foldername
)
37 return os
.path
.join(self
.directory
, foldername
)
39 def makefolder(self
, foldername
):
41 file = open(self
.getfolderfilename(foldername
), "ab")
43 # Invalidate the cache.
48 for folder
in os
.listdir(self
.directory
):
49 retval
.append(folder
.LocalStatus
.LocalStatusFolder(self
.directory
,
50 folder
, self
, self
.accountname
))
53 def getfolder(self
, foldername
):
54 return folder
.LocalStatus
.LocalStatusFolder(self
.directory
, foldername
,
55 self
, self
.accountname
)