docker-offlineimap/offlineimap/repository
Rodolfo García Peñas (kix) 63ce3f770d foldersort broken with instance comparison
This patch solves a problem about the comparison of mails used in
foldersort.

When foldersort is used, for example with:

 lambda x,y: -cmp(x,y)

The user gets an error:

ERROR: While attempting to sync account 'accountname'
  '<' not supported between instances of 'K' and 'K'

Traceback:
  File "offlineimap3/offlineimap/accounts.py", line 298, in syncrunner
    self.__sync()
  File "offlineimap3/offlineimap/accounts.py", line 374, in __sync
    remoterepos.getfolders()
  File "offlineimap3/offlineimap/repository/IMAP.py", line 725, in getfolders
    retval.sort(key=cmp2key(self.foldersort))

The problem is because in Python 3, we must specify all parameters for
total_ordering (see https://docs.python.org/3/library/functools.html in
the functools.total_ordering block):

  Given a class defining one or more rich comparison ordering methods,
  this class decorator supplies the rest. This simplifies the effort
  involved in specifying all of the possible rich comparison operations:

  The class must define one of __lt__(), __le__(), __gt__(), or __ge__().
  In addition, the class should supply an __eq__() method.

Also, see: https://docs.python.org/3.1/library/stdtypes.html#comparisons

  Instances of a class cannot be ordered with respect to other instances
  of the same class, or other types of object, unless the class defines
  enough of the methods __lt__(), __le__(), __gt__(), and __ge__()
  (in general, __lt__() and __eq__() are sufficient, if you want the
  conventional meanings of the comparison operators).

This patch implements all methods.

Closes #33
2020-12-30 21:49:19 +01:00
..
__init__.py __init__.py added explicit from in raise exceptions 2020-11-01 12:58:39 +01:00
Base.py Base.py sync_folder_structure returns always None 2020-11-01 10:00:02 +01:00
Gmail.py Gmail.py use hardcoded url variable 2/2 2020-11-01 10:06:32 +01:00
GmailMaildir.py GmailMaildir.py Removed __init__ 2020-11-01 09:13:17 +01:00
IMAP.py foldersort broken with instance comparison 2020-12-30 21:49:19 +01:00
LocalStatus.py LocalStatus.py Renamed variable 2020-11-01 12:54:59 +01:00
Maildir.py Maildir.py split long lines 2020-11-01 09:29:31 +01:00