mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipapython/graph.py String formatting
Changed string formatting for Value Errors raise. Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
parent
52a435978b
commit
fe913b9c9f
@ -24,8 +24,10 @@ class Graph(object):
|
|||||||
def add_edge(self, tail, head):
|
def add_edge(self, tail, head):
|
||||||
if tail not in self.vertices:
|
if tail not in self.vertices:
|
||||||
raise ValueError("tail is not a vertex")
|
raise ValueError("tail is not a vertex")
|
||||||
|
|
||||||
if head not in self.vertices:
|
if head not in self.vertices:
|
||||||
raise ValueError("head is not a vertex")
|
raise ValueError("head is not a vertex")
|
||||||
|
|
||||||
self.edges.append((tail, head))
|
self.edges.append((tail, head))
|
||||||
self._adj[tail].append(head)
|
self._adj[tail].append(head)
|
||||||
|
|
||||||
@ -34,14 +36,17 @@ class Graph(object):
|
|||||||
self.edges.remove((tail, head))
|
self.edges.remove((tail, head))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"graph does not contain edge: (%s, %s)" % (tail, head))
|
"graph does not contain edge: ({0}, {1})".format(tail, head)
|
||||||
|
)
|
||||||
self._adj[tail].remove(head)
|
self._adj[tail].remove(head)
|
||||||
|
|
||||||
def remove_vertex(self, vertex):
|
def remove_vertex(self, vertex):
|
||||||
try:
|
try:
|
||||||
self.vertices.remove(vertex)
|
self.vertices.remove(vertex)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise ValueError("graph does not contain vertex: %s" % vertex)
|
raise ValueError(
|
||||||
|
"graph does not contain vertex: {0}".format(vertex)
|
||||||
|
)
|
||||||
|
|
||||||
# delete _adjacencies
|
# delete _adjacencies
|
||||||
del self._adj[vertex]
|
del self._adj[vertex]
|
||||||
|
Loading…
Reference in New Issue
Block a user