Skip to content

Commit

Permalink
Bugfix: Separate try on each call to node.view()
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBB committed Apr 20, 2017
1 parent 056b8ba commit 75569a3
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions splipy/SplineModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,19 +453,24 @@ def lookup(self, obj, add=False):
# identity view on it.
try:
for candidate_node in self.internal[lower_nodes[-1]]:
return candidate_node.view(obj)
# FIXME: It might be useful to optionally not silence OrientationError,
# since that more often than not indicates a real error
except (KeyError, OrientationError):
if not add:
raise KeyError("No such object found")
node = TopologicalNode(self, obj, lower_nodes)
# Assign the new node to each possible permutation of lower-order
# nodes. This is slight overkill since some of these permutations
# are invalid, but c'est la vie.
for p in permutations(lower_nodes[-1]):
self.internal.setdefault(p, []).append(node)
return node.view()
try:
return candidate_node.view(obj)
# FIXME: It might be useful to optionally not silence OrientationError,
# since that more often than not indicates a real error
except OrientationError:
pass
except KeyError:
pass

if not add:
raise KeyError("No such object found")
node = TopologicalNode(self, obj, lower_nodes)
# Assign the new node to each possible permutation of lower-order
# nodes. This is slight overkill since some of these permutations
# are invalid, but c'est la vie.
for p in permutations(lower_nodes[-1]):
self.internal.setdefault(p, []).append(node)
return node.view()

def add(self, obj):
"""Add new nodes to the graph to accommodate the given object, then return the
Expand Down

0 comments on commit 75569a3

Please sign in to comment.