[PATCH 4/5] Don't pass in 'root' as para to LocalStatusFolders
Sebastian Spaeth
Sebastian at SSpaeth.de
Thu Sep 15 16:55:38 BST 2011
They have the Repository() which contains the root, so no need to pass
it in as an extra parameter. Rename repository.LocalStatus()'s
self.directory to self.root for consistency with other backends.
Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
offlineimap/folder/LocalStatus.py | 5 ++---
offlineimap/folder/LocalStatusSQLite.py | 6 ++----
offlineimap/repository/LocalStatus.py | 19 +++++++++----------
3 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/offlineimap/folder/LocalStatus.py b/offlineimap/folder/LocalStatus.py
index 821ad88..d03688c 100644
--- a/offlineimap/folder/LocalStatus.py
+++ b/offlineimap/folder/LocalStatus.py
@@ -26,9 +26,8 @@ except NameError:
magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT 1"
class LocalStatusFolder(BaseFolder):
- def __init__(self, root, name, repository):
+ def __init__(self, name, repository):
super(LocalStatusFolder, self).__init__(name, repository)
- self.root = root
self.sep = '.'
self.filename = os.path.join(root, self.getfolderbasename())
self.messagelist = {}
@@ -47,7 +46,7 @@ class LocalStatusFolder(BaseFolder):
return self.name
def getroot(self):
- return self.root
+ return self.repository.root
def getsep(self):
return self.sep
diff --git a/offlineimap/folder/LocalStatusSQLite.py b/offlineimap/folder/LocalStatusSQLite.py
index ba80aa1..08af807 100644
--- a/offlineimap/folder/LocalStatusSQLite.py
+++ b/offlineimap/folder/LocalStatusSQLite.py
@@ -46,10 +46,8 @@ class LocalStatusSQLiteFolder(LocalStatusFolder):
#current version of our db format
cur_version = 1
- def __init__(self, root, name, repository):
- super(LocalStatusSQLiteFolder, self).__init__(root, name,
- repository)
-
+ def __init__(self, name, repository):
+ super(LocalStatusSQLiteFolder, self).__init__(name, repository)
# dblock protects against concurrent writes in same connection
self._dblock = Lock()
#Try to establish connection, no need for threadsafety in __init__
diff --git a/offlineimap/repository/LocalStatus.py b/offlineimap/repository/LocalStatus.py
index d555064..fdd1e19 100644
--- a/offlineimap/repository/LocalStatus.py
+++ b/offlineimap/repository/LocalStatus.py
@@ -25,14 +25,14 @@ import re
class LocalStatusRepository(BaseRepository):
def __init__(self, reposname, account):
BaseRepository.__init__(self, reposname, account)
- self.directory = os.path.join(account.getaccountmeta(), 'LocalStatus')
-
- #statusbackend can be 'plain' or 'sqlite'
+ # Root directory in which the LocalStatus folders reside
+ self.root = os.path.join(account.getaccountmeta(), 'LocalStatus')
+ # statusbackend can be 'plain' or 'sqlite'
backend = self.account.getconf('status_backend', 'plain')
if backend == 'sqlite':
self._backend = 'sqlite'
self.LocalStatusFolderClass = LocalStatusSQLiteFolder
- self.directory += '-sqlite'
+ self.root += '-sqlite'
elif backend == 'plain':
self._backend = 'plain'
self.LocalStatusFolderClass = LocalStatusFolder
@@ -40,8 +40,8 @@ class LocalStatusRepository(BaseRepository):
raise SyntaxWarning("Unknown status_backend '%s' for account '%s'" \
% (backend, account.name))
- if not os.path.exists(self.directory):
- os.mkdir(self.directory, 0700)
+ if not os.path.exists(self.root):
+ os.mkdir(self.root, 0700)
# self._folders is a list of LocalStatusFolders()
self._folders = None
@@ -60,7 +60,7 @@ class LocalStatusRepository(BaseRepository):
# replace with literal 'dot' if final path name is '.' as '.' is
# an invalid file name.
basename = re.sub('(^|\/)\.$','\\1dot', basename)
- return os.path.join(self.directory, basename)
+ return os.path.join(self.root, basename)
def makefolder(self, foldername):
"""Create a LocalStatus Folder
@@ -82,8 +82,7 @@ class LocalStatusRepository(BaseRepository):
def getfolder(self, foldername):
"""Return the Folder() object for a foldername"""
- return self.LocalStatusFolderClass(self.directory, foldername,
- self)
+ return self.LocalStatusFolderClass(foldername, self)
def getfolders(self):
"""Returns a list of all cached folders."""
@@ -91,7 +90,7 @@ class LocalStatusRepository(BaseRepository):
return self._folders
self._folders = []
- for folder in os.listdir(self.directory):
+ for folder in os.listdir(self.root):
self._folders.append(self.getfolder(folder))
return self._folders
--
1.7.4.1
More information about the OfflineIMAP-project
mailing list