Set accountname in BaseFolder, and don't pass it in initialization
We passed in the accountname to all derivatives of BaseFolder, such as IMAPFolder(...,repository,...,accountname), although it is perfectly possible to get the accountname from the Repository(). So remove this unneeded parameter. Each backend had to define getaccountname() (although the function is hardly used and most accessed .accountname directly). On the other hand BaseFolder was using getaccountname but it never defined the function. So make the sane thing, remove all definitions from backends and define accountname() once in Basefolder. It was made a property and not just a (public) attribute, so it will show up in our developer documentation as public API. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:

committed by
Nicolas Sebrecht

parent
c93cd9bb1a
commit
410e2d35e9
@@ -22,13 +22,14 @@ from offlineimap import CustomConfig
|
||||
from offlineimap.ui import getglobalui
|
||||
|
||||
class BaseRepository(object, CustomConfig.ConfigHelperMixin):
|
||||
|
||||
def __init__(self, reposname, account):
|
||||
self.ui = getglobalui()
|
||||
self.account = account
|
||||
self.config = account.getconfig()
|
||||
self.name = reposname
|
||||
self.localeval = account.getlocaleval()
|
||||
self.accountname = self.account.getname()
|
||||
self._accountname = self.account.getname()
|
||||
self.uiddir = os.path.join(self.config.getmetadatadir(), 'Repository-' + self.name)
|
||||
if not os.path.exists(self.uiddir):
|
||||
os.mkdir(self.uiddir, 0700)
|
||||
@@ -71,15 +72,17 @@ class BaseRepository(object, CustomConfig.ConfigHelperMixin):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
@property
|
||||
def accountname(self):
|
||||
"""Account name as string"""
|
||||
return self._accountname
|
||||
|
||||
def getuiddir(self):
|
||||
return self.uiddir
|
||||
|
||||
def getmapdir(self):
|
||||
return self.mapdir
|
||||
|
||||
def getaccountname(self):
|
||||
return self.accountname
|
||||
|
||||
def getsection(self):
|
||||
return 'Repository ' + self.name
|
||||
|
||||
|
Reference in New Issue
Block a user