From fd9965eb9d06724c171053544f51abe56821ef78 Mon Sep 17 00:00:00 2001 From: jgoerzen Date: Thu, 4 Jul 2002 07:10:51 +0100 Subject: [PATCH] /head: changeset 70 Added the ability to filter out folders --- head/debian/changelog | 9 ++++++++ head/offlineimap.conf | 36 +++++++++++++++++++++++++++++ head/offlineimap/repository/IMAP.py | 8 ++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/head/debian/changelog b/head/debian/changelog index 9c3b2b4..e133edd 100644 --- a/head/debian/changelog +++ b/head/debian/changelog @@ -1,3 +1,12 @@ +offlineimap (2.0.0) unstable; urgency=low + + * This code is now multithreaded. New config file options control the + behavior. This can make synchronizing several times faster. + * Fixed the STATUS call to be compatible with Exchange. + * Added the ability to exclude folders. + + -- John Goerzen Wed, 3 Jul 2002 14:21:32 -0500 + offlineimap (1.0.4) unstable; urgency=low * Deletion of more than one message has been optimized. This could make diff --git a/head/offlineimap.conf b/head/offlineimap.conf index 12df513..cf02122 100644 --- a/head/offlineimap.conf +++ b/head/offlineimap.conf @@ -106,6 +106,42 @@ localfolders = ~/Test # nametrans = lambda foldername: re.sub('^INBOX.', '', foldername) +# You can specify which folders to sync. You can do it several ways. +# I'll provide some examples. The folderfilter operates on the +# *UNTRANSLATED* name, if you specify nametrans. It should return +# true if the folder is to be included; false otherwise. +# +# Example 1: synchronizing only INBOX and Sent. +# +# folderfilter = lambda foldername: foldername in ['INBOX', 'Sent'] +# +# Example 2: synchronizing everything except Trash. +# +# folderfilter = lambda foldername: foldername not in ['Trash'] +# +# Example 3: Using a regular expression to exclude Trash and all folders +# containing the characters "Del". +# +# folderfilter = lambda foldername: not re.search('(^Trash$|Del)') +# +# If folderfilter is not specified, ALL remote folders will be +# synchronized. +# +# You can span multiple lines by indenting the others. (Use backslashes +# at the end when required by Python syntax) For instance: +# +# folderfilter = lambda foldername: foldername in +# ['INBOX', 'Sent Mail', 'Deleted Items', +# 'Received'] +# +# FYI, you could also include every folder with: +# +# folderfilter = lambda foldername: 1 +# +# And exclude every folder with: +# +# folderfilter = lambda foldername: 0 + # OfflineIMAP can use multiple connections to the server in order # to perform multiple synchronization actions simultaneously. # This may place a higher burden on the server. In most cases, diff --git a/head/offlineimap/repository/IMAP.py b/head/offlineimap/repository/IMAP.py index 6fcb197..391ea7a 100644 --- a/head/offlineimap/repository/IMAP.py +++ b/head/offlineimap/repository/IMAP.py @@ -30,8 +30,11 @@ class IMAPRepository(BaseRepository): self.accountname = accountname self.folders = None self.nametrans = lambda foldername: foldername + self.folderfilter = lambda foldername: 1 if config.has_option(accountname, 'nametrans'): self.nametrans = eval(config.get(accountname, 'nametrans')) + if config.has_option(accountname, 'folderfilter'): + self.folderfilter = eval(config.get(accountname, 'folderfilter')) def getsep(self): return self.imapserver.delim @@ -54,8 +57,11 @@ class IMAPRepository(BaseRepository): flags, delim, name = imaputil.imapsplit(string) if '\\Noselect' in imaputil.flagsplit(flags): continue + foldername = imaputil.dequote(name) + if not self.folderfilter(foldername): + continue retval.append(folder.IMAP.IMAPFolder(self.imapserver, name, - self.nametrans(imaputil.dequote(name)), + self.nametrans(foldername), self.accountname)) retval.sort(lambda x, y: cmp(x.getvisiblename(), y.getvisiblename())) self.folders = retval