From 5e43d26abd676c2dcff774e73e479cf9388de56c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 23 Feb 2017 22:30:01 +0100 Subject: [PATCH] qubes: unify property ordering We already have property ordering defined in property_list(), lets move it to proper place: property.__lt__. --- qubes/__init__.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/qubes/__init__.py b/qubes/__init__.py index d33e860e..ff56dd91 100644 --- a/qubes/__init__.py +++ b/qubes/__init__.py @@ -301,9 +301,9 @@ class property(object): # pylint: disable=redefined-builtin,invalid-name def __lt__(self, other): if isinstance(other, property): - return self.__name__ < other.__name__ - else: - return self < other + return (self.load_stage, self.order, self.__name__) <\ + (other.load_stage, other.order, other.__name__) + return NotImplemented def __eq__(self, other): return isinstance(other, property) and self.__name__ == other.__name__ @@ -470,9 +470,7 @@ class PropertyHolder(qubes.events.Emitter): if load_stage is not None: props = set(prop for prop in props if prop.load_stage == load_stage) - return sorted(props, - key=lambda prop: (prop.load_stage, prop.order, prop.__name__)) - + return sorted(props) def _property_init(self, prop, value): '''Initialise property to a given value, without side effects.