1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 from portage.util.SlotObject import SlotObject
6 class Task(SlotObject):
7 __slots__ = ("_hash_key", "_hash_value")
9 def __eq__(self, other):
11 return self._hash_key == other._hash_key
12 except AttributeError:
13 # depgraph._pkg() generates _hash_key
14 # for lookups here, so handle that
15 return self._hash_key == other
17 def __ne__(self, other):
19 return self._hash_key != other._hash_key
20 except AttributeError:
24 return self._hash_value
27 return len(self._hash_key)
29 def __getitem__(self, key):
30 return self._hash_key[key]
33 return iter(self._hash_key)
35 def __contains__(self, key):
36 return key in self._hash_key
40 Emulate tuple.__repr__, but don't show 'foo' as u'foo' for unicode
43 return "(%s)" % ", ".join(("'%s'" % x for x in self._hash_key))
46 if self._hash_key is None:
47 # triggered by python-trace
48 return SlotObject.__repr__(self)
49 return "<%s (%s)>" % (self.__class__.__name__,
50 ", ".join(("'%s'" % x for x in self._hash_key)))