/offlineimap/head: changeset 255

Added folderfilter capability to the mbnames section
This commit is contained in:
jgoerzen 2002-09-30 23:09:27 +01:00
parent 5d3bb88657
commit f60d4d994b
3 changed files with 24 additions and 1 deletions

View File

@ -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 <jgoerzen@complete.org> 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

View File

@ -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
##################################################

View File

@ -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()