diff --git a/Control/AthenaCommon/python/JobProperties.py b/Control/AthenaCommon/python/JobProperties.py index 4a6805b9e973e5660297652accd66d71568eff03..a2689e55a7358cd766f481eba3682fb8388b64d6 100755 --- a/Control/AthenaCommon/python/JobProperties.py +++ b/Control/AthenaCommon/python/JobProperties.py @@ -16,6 +16,7 @@ from __future__ import print_function from past.builtins import cmp +import functools import six # @@ -101,6 +102,7 @@ class _JobPropertyMeta(type): return type.__new__( self, name, bases, dct ) +@functools.total_ordering @six.add_metaclass(_JobPropertyMeta) class JobProperty(object): """ Base class for the job properties. @@ -152,6 +154,9 @@ class JobProperty(object): def __nonzero__(self): return self.get_Value() + def __bool__(self): + return self.get_Value() + def __eq__(self, rhs): if isinstance(rhs, JobProperty): # FIXME: should we only allow comparison between same class @@ -160,6 +165,14 @@ class JobProperty(object): return self() == rhs() return self() == rhs + def __lt__(self, rhs): + if isinstance(rhs, JobProperty): + # FIXME: should we only allow comparison between same class + # rather than b/w JobProperties ? + # OTOH, JobProperty-derived classes are 'singleton'... + return self() < rhs() + return self() < rhs + def __cmp__(self, rhs): if isinstance (rhs, JobProperty): return cmp (self(), rhs())