storage: allow sorting objects with missing (receipt_)time (#36515)

This commit is contained in:
Frédéric Péters 2019-11-16 12:18:41 +01:00
parent 370357e40a
commit f4ad46acc6
1 changed files with 3 additions and 0 deletions

View File

@ -290,6 +290,9 @@ class StorableObject(object):
# on all systems so we go the cheap and almost ok way.
from .misc import simplify
key_function = lambda x: simplify(x.name)
elif order_by.endswith('_time'):
typed_none = time.gmtime(-10**10) # 1653
key_function = lambda x: getattr(x, order_by) or typed_none
else:
key_function = lambda x: getattr(x, order_by)
objects.sort(key=key_function)