BaseFolder(): Save name and repository
As all Folders share these parameters, we can safely handle them in BaseFolder. This makes sense, as BaseFolder has a getname() function that returns self.name but nothing actually set self.name. It also saves a few lines of code. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
7941ea7e7d
commit
c93cd9bb1a
@ -28,8 +28,14 @@ except NameError:
|
|||||||
from sets import Set as set
|
from sets import Set as set
|
||||||
|
|
||||||
class BaseFolder(object):
|
class BaseFolder(object):
|
||||||
def __init__(self):
|
def __init__(self, name, repository):
|
||||||
|
"""
|
||||||
|
:para name: Path & name of folder minus root or reference
|
||||||
|
:para repository: Repository() in which the folder is.
|
||||||
|
"""
|
||||||
self.ui = getglobalui()
|
self.ui = getglobalui()
|
||||||
|
self.name = name
|
||||||
|
self.repository = repository
|
||||||
|
|
||||||
def getname(self):
|
def getname(self):
|
||||||
"""Returns name"""
|
"""Returns name"""
|
||||||
|
@ -34,12 +34,12 @@ class GmailFolder(IMAPFolder):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, imapserver, name, visiblename, accountname, repository):
|
def __init__(self, imapserver, name, visiblename, accountname, repository):
|
||||||
|
super(GmailFolder, self).__init__(imapserver, name, visiblename,
|
||||||
|
accountname, repository)
|
||||||
self.realdelete = repository.getrealdelete(name)
|
self.realdelete = repository.getrealdelete(name)
|
||||||
self.trash_folder = repository.gettrashfolder(name)
|
self.trash_folder = repository.gettrashfolder(name)
|
||||||
#: Gmail will really delete messages upon EXPUNGE in these folders
|
#: Gmail will really delete messages upon EXPUNGE in these folders
|
||||||
self.real_delete_folders = [ self.trash_folder, repository.getspamfolder() ]
|
self.real_delete_folders = [ self.trash_folder, repository.getspamfolder() ]
|
||||||
IMAPFolder.__init__(self, imapserver, name, visiblename, \
|
|
||||||
accountname, repository)
|
|
||||||
|
|
||||||
def deletemessages_noconvert(self, uidlist):
|
def deletemessages_noconvert(self, uidlist):
|
||||||
uidlist = [uid for uid in uidlist if uid in self.messagelist]
|
uidlist = [uid for uid in uidlist if uid in self.messagelist]
|
||||||
|
@ -33,18 +33,17 @@ except NameError:
|
|||||||
|
|
||||||
class IMAPFolder(BaseFolder):
|
class IMAPFolder(BaseFolder):
|
||||||
def __init__(self, imapserver, name, visiblename, accountname, repository):
|
def __init__(self, imapserver, name, visiblename, accountname, repository):
|
||||||
|
name = imaputil.dequote(name)
|
||||||
|
super(IMAPFolder, self).__init__(name, repository)
|
||||||
self.config = imapserver.config
|
self.config = imapserver.config
|
||||||
self.expunge = repository.getexpunge()
|
self.expunge = repository.getexpunge()
|
||||||
self.name = imaputil.dequote(name)
|
|
||||||
self.root = None # imapserver.root
|
self.root = None # imapserver.root
|
||||||
self.sep = imapserver.delim
|
self.sep = imapserver.delim
|
||||||
self.imapserver = imapserver
|
self.imapserver = imapserver
|
||||||
self.messagelist = None
|
self.messagelist = None
|
||||||
self.visiblename = visiblename
|
self.visiblename = visiblename
|
||||||
self.accountname = accountname
|
self.accountname = accountname
|
||||||
self.repository = repository
|
|
||||||
self.randomgenerator = random.Random()
|
self.randomgenerator = random.Random()
|
||||||
BaseFolder.__init__(self)
|
|
||||||
#self.ui is set in BaseFolder
|
#self.ui is set in BaseFolder
|
||||||
|
|
||||||
def selectro(self, imapobj):
|
def selectro(self, imapobj):
|
||||||
|
@ -27,18 +27,16 @@ magicline = "OFFLINEIMAP LocalStatus CACHE DATA - DO NOT MODIFY - FORMAT 1"
|
|||||||
|
|
||||||
class LocalStatusFolder(BaseFolder):
|
class LocalStatusFolder(BaseFolder):
|
||||||
def __init__(self, root, name, repository, accountname, config):
|
def __init__(self, root, name, repository, accountname, config):
|
||||||
self.name = name
|
super(LocalStatusFolder, self).__init__(name, repository)
|
||||||
self.root = root
|
self.root = root
|
||||||
self.sep = '.'
|
self.sep = '.'
|
||||||
self.config = config
|
self.config = config
|
||||||
self.filename = os.path.join(root, self.getfolderbasename())
|
self.filename = os.path.join(root, self.getfolderbasename())
|
||||||
self.messagelist = {}
|
self.messagelist = {}
|
||||||
self.repository = repository
|
|
||||||
self.savelock = threading.Lock()
|
self.savelock = threading.Lock()
|
||||||
self.doautosave = config.getdefaultboolean("general", "fsync", False)
|
self.doautosave = config.getdefaultboolean("general", "fsync", False)
|
||||||
"""Should we perform fsyncs as often as possible?"""
|
"""Should we perform fsyncs as often as possible?"""
|
||||||
self.accountname = accountname
|
self.accountname = accountname
|
||||||
super(LocalStatusFolder, self).__init__()
|
|
||||||
|
|
||||||
def getaccountname(self):
|
def getaccountname(self):
|
||||||
return self.accountname
|
return self.accountname
|
||||||
|
@ -59,13 +59,12 @@ def gettimeseq():
|
|||||||
|
|
||||||
class MaildirFolder(BaseFolder):
|
class MaildirFolder(BaseFolder):
|
||||||
def __init__(self, root, name, sep, repository, accountname, config):
|
def __init__(self, root, name, sep, repository, accountname, config):
|
||||||
self.name = name
|
super(MaildirFolder, self).__init__(name, repository)
|
||||||
self.config = config
|
self.config = config
|
||||||
self.dofsync = 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
|
||||||
self.repository = repository
|
|
||||||
self.accountname = accountname
|
self.accountname = accountname
|
||||||
|
|
||||||
self.wincompatible = self.config.getdefaultboolean(
|
self.wincompatible = self.config.getdefaultboolean(
|
||||||
@ -77,8 +76,6 @@ class MaildirFolder(BaseFolder):
|
|||||||
self.infosep = '!'
|
self.infosep = '!'
|
||||||
|
|
||||||
self.flagmatchre = re.compile(self.infosep + '.*2,([A-Z]+)')
|
self.flagmatchre = re.compile(self.infosep + '.*2,([A-Z]+)')
|
||||||
|
|
||||||
BaseFolder.__init__(self)
|
|
||||||
#self.ui is set in BaseFolder.init()
|
#self.ui is set in BaseFolder.init()
|
||||||
# Cache the full folder path, as we use getfullname() very often
|
# Cache the full folder path, as we use getfullname() very often
|
||||||
self._fullname = os.path.join(self.getroot(), self.getname())
|
self._fullname = os.path.join(self.getroot(), self.getname())
|
||||||
|
Loading…
Reference in New Issue
Block a user