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.ui = getglobalui()
self.name = name self.name = name
self.repository = repository self.repository = repository
self.config = repository.getconfig()
def getname(self): def getname(self):
"""Returns name""" """Returns name"""

View File

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

View File

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

View File

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

View File

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

View File

@ -83,8 +83,7 @@ class LocalStatusRepository(BaseRepository):
def getfolder(self, foldername): def getfolder(self, foldername):
"""Return the Folder() object for a foldername""" """Return the Folder() object for a foldername"""
return self.LocalStatusFolderClass(self.directory, foldername, return self.LocalStatusFolderClass(self.directory, foldername,
self, self)
self.config)
def getfolders(self): def getfolders(self):
"""Returns a list of all cached folders.""" """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'): if self.config.has_option('Repository ' + self.name, 'restoreatime') and self.config.getboolean('Repository ' + self.name, 'restoreatime'):
self._append_folder_atimes(foldername) self._append_folder_atimes(foldername)
return folder.Maildir.MaildirFolder(self.root, foldername, return folder.Maildir.MaildirFolder(self.root, foldername,
self.getsep(), self, self.getsep(), self)
self.config)
def _getfolders_scandir(self, root, extension = None): def _getfolders_scandir(self, root, extension = None):
"""Recursively scan folder 'root'; return a list of MailDirFolder """Recursively scan folder 'root'; return a list of MailDirFolder
@ -167,8 +166,7 @@ class MaildirRepository(BaseRepository):
retval.append(folder.Maildir.MaildirFolder(self.root, retval.append(folder.Maildir.MaildirFolder(self.root,
foldername, foldername,
self.getsep(), self.getsep(),
self, self))
self.config))
if self.getsep() == '/' and dirname != '.': if self.getsep() == '/' and dirname != '.':
# Recursively check sub-directories for folders too. # Recursively check sub-directories for folders too.
retval.extend(self._getfolders_scandir(root, foldername)) retval.extend(self._getfolders_scandir(root, foldername))