/head: changeset 70
Added the ability to filter out folders
This commit is contained in:
parent
1549691ec7
commit
fd9965eb9d
@ -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 <jgoerzen@complete.org> 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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user