From bf1b995908823fb7e29401d169c4e76a73b953f9 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 1 Nov 2011 22:20:46 +0100 Subject: [PATCH] implement __lt__ and __eq__ to support sorting a list of types Signed-off-by: Steven Armstrong --- lib/cdist/core/type.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/cdist/core/type.py b/lib/cdist/core/type.py index e9cb375a..20365b8d 100644 --- a/lib/cdist/core/type.py +++ b/lib/cdist/core/type.py @@ -86,6 +86,12 @@ class Type(object): def __repr__(self): return '' % self.name + def __eq__(self, other): + return isinstance(other, self.__class__) and self.name == other.name + + def __lt__(self, other): + return isinstance(other, self.__class__) and self.name < other.name + @property def is_singleton(self): """Check whether a type is a singleton."""