From ae57f463d8dfd2ac4c9870af7a99a2ede597e5d7 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Thu, 24 Dec 2015 15:56:07 +0100 Subject: [PATCH 1/1] LazyUUIDTaskSet: Add additional methods to simulate the set object --- tasklib/lazy.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tasklib/lazy.py b/tasklib/lazy.py index b26f964..543abf0 100644 --- a/tasklib/lazy.py +++ b/tasklib/lazy.py @@ -91,6 +91,9 @@ class LazyUUIDTaskSet(object): def __eq__(self, other): return set(t['uuid'] for t in other) == self._uuids + def __ne__(self, other): + return not (self == other) + def __contains__(self, task): return task['uuid'] in self._uuids @@ -101,6 +104,22 @@ class LazyUUIDTaskSet(object): for uuid in self._uuids: yield LazyUUIDTask(self._tw, uuid) + def __sub__(self, other): + return LazyUUIDTaskSet(self._tw, + self._uuids - set(t['uuid'] for t in other)) + + def __isub__(self, other): + self._uuids -= set(t['uuid'] for t in other) + return self + + def __or__(self, other): + return LazyUUIDTaskSet(self._tw, + self._uuids | set(t['uuid'] for t in other)) + + def __ior__(self, other): + self._uuids |= set(t['uuid'] for t in other) + return self + def replace(self): """ Performs conversion to the regular TaskQuerySet object, referenced by -- 2.39.5