blob: 3dd11930494d6b3ccc97f784384636df7d519a8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from _emerge.SlotObject import SlotObject
class Task(SlotObject):
__slots__ = ("_hash_key", "_hash_value")
def __eq__(self, other):
return self._hash_key == other
def __ne__(self, other):
return self._hash_key != other
def __hash__(self):
hash_value = getattr(self, "_hash_value", None)
if hash_value is None:
self._hash_value = hash(self._hash_key)
return self._hash_value
def __len__(self):
return len(self._hash_key)
def __getitem__(self, key):
return self._hash_key[key]
def __iter__(self):
return iter(self._hash_key)
def __contains__(self, key):
return key in self._hash_key
def __str__(self):
"""
Emulate tuple.__repr__, but don't show 'foo' as u'foo' for unicode
strings.
"""
return "(%s)" % ", ".join(("'%s'" % x for x in self._hash_key))
|