Remove 'config' as parameter from BaseFolder & derivatives

It is possible to get the config parameter from the Repository() which is
set in BaseFolder, so we set self.config there and remove the various
methods and 'config' parameters that are superfluous.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-09-16 10:54:24 +02:00 committed by Nicolas Sebrecht
parent 410e2d35e9
commit ee75e0921f
7 changed files with 11 additions and 16 deletions

View File

@ -36,6 +36,7 @@ class BaseFolder(object):
self.ui = getglobalui()
self.name = name
self.repository = repository
self.config = repository.getconfig()
def getname(self):
"""Returns name"""

View File

@ -35,7 +35,6 @@ class IMAPFolder(BaseFolder):
def __init__(self, imapserver, name, visiblename, repository):
name = imaputil.dequote(name)
super(IMAPFolder, self).__init__(name, repository)
self.config = imapserver.config
self.expunge = repository.getexpunge()
self.root = None # imapserver.root
self.sep = imapserver.delim

View File

@ -26,15 +26,15 @@ except NameError:
magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT 1"
class LocalStatusFolder(BaseFolder):
def __init__(self, root, name, repository, config):
def __init__(self, root, name, repository):
super(LocalStatusFolder, self).__init__(name, repository)
self.root = root
self.sep = '.'
self.config = config
self.filename = os.path.join(root, self.getfolderbasename())
self.messagelist = {}
self.savelock = threading.Lock()
self.doautosave = config.getdefaultboolean("general", "fsync", False)
self.doautosave = self.config.getdefaultboolean("general", "fsync",
False)
"""Should we perform fsyncs as often as possible?"""
def storesmessages(self):

View File

@ -46,10 +46,9 @@ class LocalStatusSQLiteFolder(LocalStatusFolder):
#current version of our db format
cur_version = 1
def __init__(self, root, name, repository, config):
def __init__(self, root, name, repository):
super(LocalStatusSQLiteFolder, self).__init__(root, name,
repository,
config)
repository)
# dblock protects against concurrent writes in same connection
self._dblock = Lock()

View File

@ -58,10 +58,9 @@ def gettimeseq():
timelock.release()
class MaildirFolder(BaseFolder):
def __init__(self, root, name, sep, repository, config):
def __init__(self, root, name, sep, repository):
super(MaildirFolder, self).__init__(name, repository)
self.config = config
self.dofsync = config.getdefaultboolean("general", "fsync", True)
self.dofsync = self.config.getdefaultboolean("general", "fsync", True)
self.root = root
self.sep = sep
self.messagelist = None

View File

@ -83,8 +83,7 @@ class LocalStatusRepository(BaseRepository):
def getfolder(self, foldername):
"""Return the Folder() object for a foldername"""
return self.LocalStatusFolderClass(self.directory, foldername,
self,
self.config)
self)
def getfolders(self):
"""Returns a list of all cached folders."""

View File

@ -117,8 +117,7 @@ class MaildirRepository(BaseRepository):
if self.config.has_option('Repository ' + self.name, 'restoreatime') and self.config.getboolean('Repository ' + self.name, 'restoreatime'):
self._append_folder_atimes(foldername)
return folder.Maildir.MaildirFolder(self.root, foldername,
self.getsep(), self,
self.config)
self.getsep(), self)
def _getfolders_scandir(self, root, extension = None):
"""Recursively scan folder 'root'; return a list of MailDirFolder
@ -167,8 +166,7 @@ class MaildirRepository(BaseRepository):
retval.append(folder.Maildir.MaildirFolder(self.root,
foldername,
self.getsep(),
self,
self.config))
self))
if self.getsep() == '/' and dirname != '.':
# Recursively check sub-directories for folders too.
retval.extend(self._getfolders_scandir(root, foldername))