From bdf38344ffb6dbbd7ed5a4d04a164741fe4a39a0 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Fri, 26 Sep 2014 16:39:16 +0100 Subject: [PATCH] 8015: Update location utilities to work with proxies --- gramps/gen/utils/location.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gramps/gen/utils/location.py b/gramps/gen/utils/location.py index 6c937351d..78f7f70a0 100644 --- a/gramps/gen/utils/location.py +++ b/gramps/gen/utils/location.py @@ -40,6 +40,8 @@ def get_location_list(db, place): else: visited.append(handle) place = db.get_place_from_handle(handle) + if place is None: + break lines.append(place.name) return lines @@ -62,6 +64,8 @@ def get_main_location(db, place): else: visited.append(handle) place = db.get_place_from_handle(handle) + if place is None: + break items[int(place.get_type())] = place.name return items @@ -83,10 +87,11 @@ def get_locations(db, place): for parent in place.get_placeref_list(): if parent.ref not in visited: parent_place = db.get_place_from_handle(parent.ref) - parent_tree = tree + [(int(parent_place.get_type()), - parent_place.get_all_names())] - parent_visited = visited + [parent.ref] - todo.append((parent_place, parent_tree, parent_visited)) + if parent_place is not None: + parent_tree = tree + [(int(parent_place.get_type()), + parent_place.get_all_names())] + parent_visited = visited + [parent.ref] + todo.append((parent_place, parent_tree, parent_visited)) if len(place.get_placeref_list()) == 0: locations.append(dict(tree)) return locations @@ -110,6 +115,7 @@ def located_in(db, handle1, handle2): return True if parent.ref not in visited: parent_place = db.get_place_from_handle(parent.ref) - parent_visited = visited + [parent.ref] - todo.append((parent_place, parent_visited)) + if parent_place is not None: + parent_visited = visited + [parent.ref] + todo.append((parent_place, parent_visited)) return False