]> git.madduck.net Git - etc/offlineimap.git/blob - .offlineimap/helper.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

d758d9527834c7d78e1ed3857a5899aa320b661a
[etc/offlineimap.git] / .offlineimap / helper.py
1 # -*- coding: utf-8 -*-
2
3 import re
4
5 base_excludes = ['delayed', 'outgoing', 'Trash', 'Queue', 'inbox', 'Spam', 'Sent', 'Drafts']
6 base_excludes_re = [ '[Ss]ent.*' ]
7 full_excludes_re = ['discard', 'spool', 'spam', 'store/.+']
8 prioritised = ['resubmit','drafts','inbox','ardex','kbkg','toni','tahi','debian','mtfk','admin','retrain']
9 deprioritised = ['discard','spam','store','spool']
10
11 def py_foldersort_main(x, y):
12     for prefix in prioritised:
13         if x.startswith(prefix):
14             return -1
15         elif y.startswith(prefix):
16             return +1
17     for prefix in deprioritised:
18         if x.startswith(prefix):
19             return +1
20         elif y.startswith(prefix):
21             return -1
22     return (x > y) - (x < y)
23
24 def py_nametrans(x):
25     return re.sub('^INBOX', 'inbox', x)
26
27 def py_folderfilter_main(x):
28     if x in base_excludes:
29         return False
30
31     elif re.search('^(' + '|'.join(base_excludes_re) + ')', x):
32         return False
33
34     elif re.search('^(' + '|'.join(full_excludes_re) + ')', x):
35         return False
36
37     return True
38
39 def py_foldersort_bulk(x, y):
40     if x == 'spool': return -1
41     if y == 'spool': return  1
42     if x in ('discard', 'spam'): return 1
43     if y in ('discard', 'spam'): return -1
44
45 def py_folderfilter_bulk(x):
46     if re.search('^(' + '|'.join(full_excludes_re) + ')', x):
47         return True
48
49     return False
50
51 def py_folderfilter_mbnames(acct, x):
52     full_excludes_re_mbnames = ['retrain(/(sp|h)am)?$'] + full_excludes_re
53     return acct in ['madduck.net', 'madduck.net_bulk'] \
54             and not re.search('^(' + '|'.join(full_excludes_re_mbnames) + ')', x)