From 9c5f73d3b34f29eb5e4ea5ca157f8b058684c9bc Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Mon, 29 Aug 2011 15:08:26 +0200 Subject: [PATCH] Move self.folderfilter|nametrans|sort from IMAPFolder to BaseFolder We want to have these functions available for Maildir folders too, so we can folderfilter a Maildir repository too (which is currently not possible) This commit only move the corresponding functions from the IMAP to the Base implementation. It should not change behavior in any way yet. Signed-off-by: Sebastian Spaeth --- offlineimap/repository/Base.py | 18 ++++++++++++++++++ offlineimap/repository/IMAP.py | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/offlineimap/repository/Base.py b/offlineimap/repository/Base.py index ae17ee8..76fa4a3 100644 --- a/offlineimap/repository/Base.py +++ b/offlineimap/repository/Base.py @@ -16,6 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +import re import os.path import traceback from offlineimap import CustomConfig @@ -40,6 +41,23 @@ class BaseRepository(object, CustomConfig.ConfigHelperMixin): if not os.path.exists(self.uiddir): os.mkdir(self.uiddir, 0700) + self.nametrans = lambda foldername: foldername + self.folderfilter = lambda foldername: 1 + self.folderincludes = [] + self.foldersort = cmp + if self.config.has_option(self.getsection(), 'nametrans'): + self.nametrans = self.localeval.eval( + self.getconf('nametrans'), {'re': re}) + if self.config.has_option(self.getsection(), 'folderfilter'): + self.folderfilter = self.localeval.eval( + self.getconf('folderfilter'), {'re': re}) + if self.config.has_option(self.getsection(), 'folderincludes'): + self.folderincludes = self.localeval.eval( + self.getconf('folderincludes'), {'re': re}) + if self.config.has_option(self.getsection(), 'foldersort'): + self.foldersort = self.localeval.eval( + self.getconf('foldersort'), {'re': re}) + def restore_atime(self): """Sets folders' atime back to their values after a sync diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py index 03dc5ec..5ddf5b9 100644 --- a/offlineimap/repository/IMAP.py +++ b/offlineimap/repository/IMAP.py @@ -21,7 +21,6 @@ from offlineimap import folder, imaputil, imapserver, OfflineImapError from offlineimap.folder.UIDMaps import MappedIMAPFolder from offlineimap.threadutil import ExitNotifyThread from threading import Event -import re import types import os from sys import exc_info @@ -36,23 +35,6 @@ class IMAPRepository(BaseRepository): self._host = None self.imapserver = imapserver.IMAPServer(self) self.folders = None - self.nametrans = lambda foldername: foldername - self.folderfilter = lambda foldername: 1 - self.folderincludes = [] - self.foldersort = cmp - localeval = self.localeval - if self.config.has_option(self.getsection(), 'nametrans'): - self.nametrans = localeval.eval(self.getconf('nametrans'), - {'re': re}) - if self.config.has_option(self.getsection(), 'folderfilter'): - self.folderfilter = localeval.eval(self.getconf('folderfilter'), - {'re': re}) - if self.config.has_option(self.getsection(), 'folderincludes'): - self.folderincludes = localeval.eval(self.getconf('folderincludes'), - {'re': re}) - if self.config.has_option(self.getsection(), 'foldersort'): - self.foldersort = localeval.eval(self.getconf('foldersort'), - {'re': re}) def startkeepalive(self): keepalivetime = self.getkeepalive()