Gentoo Archives: gentoo-portage-dev

From: Sebastian Luther <SebastianLuther@×××.de>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH 09/10] Add digraph.discard
Date: Wed, 29 Jan 2014 15:34:53
Message-Id: 1391009594-22750-10-git-send-email-SebastianLuther@gmx.de
In Reply to: [gentoo-portage-dev] [PATCH 00/10] First steps to get rid of backtracking by Sebastian Luther
1 ---
2 pym/portage/util/digraph.py | 12 +++++++++++-
3 1 file changed, 11 insertions(+), 1 deletion(-)
4
5 diff --git a/pym/portage/util/digraph.py b/pym/portage/util/digraph.py
6 index fc1fb86..4a9cb43 100644
7 --- a/pym/portage/util/digraph.py
8 +++ b/pym/portage/util/digraph.py
9 @@ -1,4 +1,4 @@
10 -# Copyright 2010-2013 Gentoo Foundation
11 +# Copyright 2010-2014 Gentoo Foundation
12 # Distributed under the terms of the GNU General Public License v2
13
14 from __future__ import unicode_literals
15 @@ -47,6 +47,16 @@ class digraph(object):
16 priorities.append(priority)
17 priorities.sort()
18
19 + def discard(self, node):
20 + """
21 + Like remove(), except it doesn't raises KeyError if the
22 + node doesn't exist.
23 + """
24 + try:
25 + self.remove(node)
26 + except KeyError:
27 + pass
28 +
29 def remove(self, node):
30 """Removes the specified node from the digraph, also removing
31 and ties to other nodes in the digraph. Raises KeyError if the
32 --
33 1.8.3.2