]> 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:

only ignore actual retrain folders in mbnames
[etc/offlineimap.git] / .offlineimap / helper.py
1 def py_foldersort_seamus(x, y):
2     prioritised = ('outgoing','resubmit','drafts','inbox','phd','ul','debian','sudetia','admin','retrain')
3     deprioritised = ('discard','spam','store','spool')
4     for prefix in prioritised:
5         if x.startswith(prefix):
6             return -1
7         elif y.startswith(prefix):
8             return +1
9     for prefix in deprioritised:
10         if x.startswith(prefix):
11             return +1
12         elif y.startswith(prefix):
13             return -1
14     return cmp(x, y)
15
16 import re
17
18 def py_nametrans_seamus(x):
19     return re.sub('^INBOX', 'inbox', x)
20
21 def should_do_full_sync():
22     import os, stat, time
23     FILE = os.path.expanduser('~/.var/offlineimap/lastrun')
24     INTERVAL = 30
25     now = int(time.time())
26
27     try:
28         mtime = os.stat(FILE)[stat.ST_MTIME]
29     except OSError:
30         mtime = 0
31
32     since = now - mtime
33     print 'now=%d mtime=%d since=%d INTERVAL=%d' \
34             % (now, mtime, since, INTERVAL)
35     if since > INTERVAL:
36         file(FILE, 'wb').close()
37         print 'Running a full sync...'
38         return True
39
40     print 'Running a partial sync, next full sync in %d seconds...' \
41             % (INTERVAL - since)
42     return False
43
44 #do_full = should_do_full_sync()
45 do_full = True
46 def py_folderfilter_seamus(x):
47     base_excludes = ['delayed', 'outgoing', 'Trash', 'Sent']
48
49     if do_full:
50         return x not in base_excludes
51     else:
52         if x in base_excludes:
53             return False
54         if x in ('spool', 'discard', 'spam'):
55             return False
56         if re.search('^store\..+', x):
57             return False
58     return True
59
60 def py_folderfilter_mbnames(acct, x):
61     return not re.search('^(store(/.+)?|retrain/(ham|spam)|spool|discard|spam)', x)