[PATCH 6/8] Move self.folderfilter|nametrans|sort from IMAPFolder to BaseFolder
Sebastian Spaeth
Sebastian at SSpaeth.de
Mon Aug 29 15:00:15 BST 2011
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 <Sebastian at SSpaeth.de>
---
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 5c54afc..39ce653 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 sys import exc_info
@@ -41,6 +42,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})
+
# The 'restoreatime' config parameter only applies to local Maildir
# mailboxes.
def restore_atime(self):
diff --git a/offlineimap/repository/IMAP.py b/offlineimap/repository/IMAP.py
index 4ca7494..55db831 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()
--
1.7.4.1
More information about the OfflineIMAP-project
mailing list