diff options
| author | Ryan Kavanagh <rak@debian.org> | 2012-09-30 11:55:38 +0100 | 
|---|---|---|
| committer | Ryan Kavanagh <rak@debian.org> | 2012-09-30 11:55:38 +0100 | 
| commit | aa075731677b80876233fb1244aa7a0db1e93cdc (patch) | |
| tree | c505ac346c5331c0695d7b1b52bae16578b07182 /.offlineimap.py | |
| parent | Don't require the SAIL schedule to be read, filter it away automatically (diff) | |
Programmatically decide on the version of mycmp to use based on offlineimap.__version__
Diffstat (limited to '.offlineimap.py')
| -rw-r--r-- | .offlineimap.py | 19 | 
1 files changed, 19 insertions, 0 deletions
diff --git a/.offlineimap.py b/.offlineimap.py index 2d1f5f9..eb6a9bf 100644 --- a/.offlineimap.py +++ b/.offlineimap.py @@ -1,8 +1,27 @@ +import offlineimap  import re  prioritized = ['INBOX', 'QueensU.INBOX']  def mycmp(x, y): +  if offlineimap.__version__ < '6.4': +    return mycmp_oldofflineimap(x, y) +  else: +    return mycmp_newofflineimap(x, y) + +def mycmp_oldofflineimap(x, y): +  for prefix in prioritized: +    xsw = x.startswith(prefix) +    ysw = y.startswith(prefix) +    if xsw and ysw: +      return cmp(x, y) +    elif xsw: +      return -1 +    elif ysw: +      return +1 +  return cmp(x, y) + +def mycmp_newofflineimap(x, y):    for prefix in prioritized:      xsw = x.visiblename.startswith(prefix)      ysw = y.visiblename.startswith(prefix)  | 
