[gen] Stop using param 'cmp' in method [].sort (deprecated in Python3). Used para 'key' instead.

This commit is contained in:
Gaetan Delannay 2013-01-22 09:12:00 +01:00
parent b3ff087e8f
commit cb77418dda
2 changed files with 3 additions and 4 deletions

View file

@ -302,7 +302,7 @@ class Calendar(Type):
singleRes = (date, event) singleRes = (date, event)
res.append(singleRes) res.append(singleRes)
# Sort the result if required # Sort the result if required
if sorted: res.sort(lambda x,y: cmp(x[0], y[0])) if sorted: res.sort(key=lambda x: x[0])
# Group events spanned on several days if required # Group events spanned on several days if required
if groupSpanned: if groupSpanned:
# Browse events in reverse order and merge them when appropriate # Browse events in reverse order and merge them when appropriate

View file

@ -177,9 +177,8 @@ class AbstractWrapper(object):
refs = getattr(self.o, fieldName, None) refs = getattr(self.o, fieldName, None)
if not refs: return if not refs: return
tool = self.tool tool = self.tool
refs.sort(lambda x,y: cmp(getattr(tool.getObject(x), sortKey), refs.sort(key=lambda x: getattr(tool.getObject(x), sortKey),
getattr(tool.getObject(y), sortKey))) reverse=reverse)
if reverse: refs.reverse()
def create(self, fieldNameOrClass, noSecurity=False, **kwargs): def create(self, fieldNameOrClass, noSecurity=False, **kwargs):
'''If p_fieldNameOrClass is the name of a field, this method allows to '''If p_fieldNameOrClass is the name of a field, this method allows to