diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-05-17 18:43:32 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-05-17 18:43:32 -0700 |
commit | 6201d99b8be4da50fc203ef5b758044defa80b0b (patch) | |
tree | 9b1d5aaa6013963342c7843a03b04bc0277e8a62 | |
parent | 6186114119ca8b94a51504bfc551ebe4b5cf1098 (diff) | |
download | portage-6201d99b8be4da50fc203ef5b758044defa80b0b.tar.gz portage-6201d99b8be4da50fc203ef5b758044defa80b0b.tar.bz2 portage-6201d99b8be4da50fc203ef5b758044defa80b0b.zip |
digraph: implement __bool__
-rw-r--r-- | pym/portage/util/digraph.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/pym/portage/util/digraph.py b/pym/portage/util/digraph.py index df024fb4b..1bbe10f61 100644 --- a/pym/portage/util/digraph.py +++ b/pym/portage/util/digraph.py @@ -1,9 +1,11 @@ -# Copyright 2010 Gentoo Foundation +# Copyright 2010-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 __all__ = ['digraph'] from collections import deque +import sys + from portage import _unicode_decode from portage.util import writemsg @@ -221,6 +223,9 @@ class digraph(object): root_nodes.append(node) return root_nodes + def __bool__(self): + return bool(self.nodes) + def is_empty(self): """Checks if the digraph is empty""" return len(self.nodes) == 0 @@ -332,3 +337,6 @@ class digraph(object): __contains__ = contains empty = is_empty copy = clone + + if sys.hexversion < 0x3000000: + __nonzero__ = __bool__ |