From 3ee4bf8d4f764461d43a50b1b7b737066bd33381 Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Wed, 9 Oct 2024 14:34:09 -0700 Subject: [PATCH] support ordering for some cases.. --- ui/medashare/mdb.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/medashare/mdb.py b/ui/medashare/mdb.py index 937f244..a477d05 100644 --- a/ui/medashare/mdb.py +++ b/ui/medashare/mdb.py @@ -1,6 +1,7 @@ import base64 import copy import datetime +import functools import itertools import json import unittest @@ -31,6 +32,7 @@ class _TestJSONEncoder(unittest.TestCase): # XXX - add validation # XXX - how to add singletons +@functools.total_ordering class MDBase(object): '''This is a simple wrapper that turns a JSON object into a pythonesc object where attribute accesses work.''' @@ -170,6 +172,10 @@ class MDBase(object): return self._obj + def __lt__(self, o): + return (self['type'], self['uuid'], self['modified']) < \ + (o['type'], o['uuid'], o['modified']) + def __eq__(self, o): return self._obj == o