From: Zac Medico Date: Fri, 20 May 2011 06:23:51 +0000 (-0700) Subject: Task: remove unnecessary _get_hash_key() method X-Git-Tag: v2.1.9.50~72 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=164647b7fa04e80f3018070c2d029b22d60cb02f;p=portage.git Task: remove unnecessary _get_hash_key() method --- diff --git a/pym/_emerge/Blocker.py b/pym/_emerge/Blocker.py index 5c335b066..4f61c887d 100644 --- a/pym/_emerge/Blocker.py +++ b/pym/_emerge/Blocker.py @@ -1,4 +1,4 @@ -# Copyright 1999-2010 Gentoo Foundation +# Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from _emerge.Task import Task @@ -11,11 +11,4 @@ class Blocker(Task): def __init__(self, **kwargs): Task.__init__(self, **kwargs) self.cp = self.atom.cp - - def _get_hash_key(self): - hash_key = getattr(self, "_hash_key", None) - if hash_key is None: - self._hash_key = \ - ("blocks", self.root, self.atom, self.eapi) - return self._hash_key - + self._hash_key = ("blocks", self.root, self.atom, self.eapi) diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index d7efbf2ae..3f76c0edd 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -407,9 +407,6 @@ class Package(Task): missing_iuse.append(flag) return missing_iuse - def _get_hash_key(self): - return self._hash_key - def __lt__(self, other): if other.cp != self.cp: return False diff --git a/pym/_emerge/Task.py b/pym/_emerge/Task.py index 31788b576..3dd119304 100644 --- a/pym/_emerge/Task.py +++ b/pym/_emerge/Task.py @@ -1,43 +1,37 @@ -# Copyright 1999-2009 Gentoo Foundation +# 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 _get_hash_key(self): - try: - return self._hash_key - except AttributeError: - raise NotImplementedError(self) - def __eq__(self, other): - return self._get_hash_key() == other + return self._hash_key == other def __ne__(self, other): - return self._get_hash_key() != 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._get_hash_key()) + self._hash_value = hash(self._hash_key) return self._hash_value def __len__(self): - return len(self._get_hash_key()) + return len(self._hash_key) def __getitem__(self, key): - return self._get_hash_key()[key] + return self._hash_key[key] def __iter__(self): - return iter(self._get_hash_key()) + return iter(self._hash_key) def __contains__(self, key): - return key in self._get_hash_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._get_hash_key())) + return "(%s)" % ", ".join(("'%s'" % x for x in self._hash_key))