summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-07-26 15:02:50 +0100
committerBenjamin Schubert <contact@benschubert.me>2019-07-29 10:42:02 +0100
commit0dacf84b3655fbe1e4da8f4a2f56a86aef9d89e4 (patch)
tree5ea7575bc5a0e524215fc183e0492e56af598b67
parent90da23867767905c39bf8199c2b8a4d6e13a5c95 (diff)
downloadbuildstream-0dacf84b3655fbe1e4da8f4a2f56a86aef9d89e4.tar.gz
types: Mark 'Consistency' as a 'FastEnum'
This allows for stronger guarantees when checking the level of consistency since it will only be comparable with itself, and ensures unicity
-rw-r--r--src/buildstream/types.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/buildstream/types.py b/src/buildstream/types.py
index dc40bd16f..56f5b99f0 100644
--- a/src/buildstream/types.py
+++ b/src/buildstream/types.py
@@ -104,7 +104,7 @@ class Scope(FastEnum):
"""
-class Consistency():
+class Consistency(FastEnum):
"""Defines the various consistency states of a :class:`.Source`.
"""
@@ -128,6 +128,16 @@ class Consistency():
Sources have a cached unstaged copy in the source directory.
"""
+ def __ge__(self, other):
+ if self.__class__ is not other.__class__:
+ raise ValueError("Unexpected comparison between {} and {}".format(self, repr(other)))
+ return self.value >= other.value
+
+ def __lt__(self, other):
+ if self.__class__ is not other.__class__:
+ raise ValueError("Unexpected comparison between {} and {}".format(self, repr(other)))
+ return self.value < other.value
+
class CoreWarnings():
"""CoreWarnings()