From f60d4d994b5347a99012d06633a2516002ed33d4 Mon Sep 17 00:00:00 2001 From: jgoerzen Date: Mon, 30 Sep 2002 23:09:27 +0100 Subject: [PATCH] /offlineimap/head: changeset 255 Added folderfilter capability to the mbnames section --- offlineimap/head/debian/changelog | 7 +++++++ offlineimap/head/offlineimap.conf | 9 +++++++++ offlineimap/head/offlineimap/mbnames.py | 9 ++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/offlineimap/head/debian/changelog b/offlineimap/head/debian/changelog index ee2e990..92d30e8 100644 --- a/offlineimap/head/debian/changelog +++ b/offlineimap/head/debian/changelog @@ -1,3 +1,10 @@ +offlineimap (3.2.9) unstable; urgency=low + + * Added folderfilter capability to mbnames recorder. You can now omit + specified folders from the mbnames output. + + -- John Goerzen Mon, 30 Sep 2002 12:08:08 -0500 + offlineimap (3.2.8) unstable; urgency=low * Added a work-around for some IMAP servers that respond poorly diff --git a/offlineimap/head/offlineimap.conf b/offlineimap/head/offlineimap.conf index 2b9fee4..248d61f 100644 --- a/offlineimap/head/offlineimap.conf +++ b/offlineimap/head/offlineimap.conf @@ -108,6 +108,15 @@ peritem = "+%(accountname)s/%(foldername)s" sep = " " footer = "\n" +# You can also specify a folderfilter. It will apply to the +# *translated* folder name here, and it takes TWO arguments: +# accountname and foldername. In all other ways, it will +# behave identically to the folderfilter for accounts. Please see +# that section for more information and examples. +# +# Note that this filter can be used only to further restrict mbnames +# to a subset of folders that pass the account's folderfilter. + ################################################## # Blinkenlights configuration ################################################## diff --git a/offlineimap/head/offlineimap/mbnames.py b/offlineimap/head/offlineimap/mbnames.py index 9329c4d..8c0298b 100644 --- a/offlineimap/head/offlineimap/mbnames.py +++ b/offlineimap/head/offlineimap/mbnames.py @@ -17,6 +17,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import os.path +import re # for folderfilter def genmbnames(config, localeval, boxlist): """Takes a configparser object and a boxlist, which is a list of hashes @@ -25,7 +26,13 @@ def genmbnames(config, localeval, boxlist): return file = open(os.path.expanduser(config.get("mbnames", "filename")), "wt") file.write(localeval.eval(config.get("mbnames", "header"))) - itemlist = [localeval.eval(config.get("mbnames", "peritem", raw=1)) % item for item in boxlist] + folderfilter = lambda foldername: 1 + if config.has_option("mbnames", "folderfilter"): + folderfilter = localeval.eval(config.get("mbnames", "folderfilter"), + {'re': re}) + itemlist = [localeval.eval(config.get("mbnames", "peritem", raw=1)) % item\ + for item in boxlist \ + if folderfilter(item['accountname'], item['foldername'])] file.write(localeval.eval(config.get("mbnames", "sep")).join(itemlist)) file.write(localeval.eval(config.get("mbnames", "footer"))) file.close()