Browse Source

support ordering for some cases..

main
John-Mark Gurney 4 months ago
parent
commit
3ee4bf8d4f
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      ui/medashare/mdb.py

+ 6
- 0
ui/medashare/mdb.py View File

@@ -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



Loading…
Cancel
Save