8015: Update location utilities to work with proxies

This commit is contained in:
Nick Hall 2014-09-26 16:39:16 +01:00
parent c667cd5430
commit 082b7c8940

View File

@ -40,6 +40,8 @@ def get_location_list(db, place):
else: else:
visited.append(handle) visited.append(handle)
place = db.get_place_from_handle(handle) place = db.get_place_from_handle(handle)
if place is None:
break
lines.append(place.name) lines.append(place.name)
return lines return lines
@ -62,6 +64,8 @@ def get_main_location(db, place):
else: else:
visited.append(handle) visited.append(handle)
place = db.get_place_from_handle(handle) place = db.get_place_from_handle(handle)
if place is None:
break
items[int(place.get_type())] = place.name items[int(place.get_type())] = place.name
return items return items
@ -83,6 +87,7 @@ def get_locations(db, place):
for parent in place.get_placeref_list(): for parent in place.get_placeref_list():
if parent.ref not in visited: if parent.ref not in visited:
parent_place = db.get_place_from_handle(parent.ref) parent_place = db.get_place_from_handle(parent.ref)
if parent_place is not None:
parent_tree = tree + [(int(parent_place.get_type()), parent_tree = tree + [(int(parent_place.get_type()),
parent_place.get_all_names())] parent_place.get_all_names())]
parent_visited = visited + [parent.ref] parent_visited = visited + [parent.ref]
@ -110,6 +115,7 @@ def located_in(db, handle1, handle2):
return True return True
if parent.ref not in visited: if parent.ref not in visited:
parent_place = db.get_place_from_handle(parent.ref) parent_place = db.get_place_from_handle(parent.ref)
if parent_place is not None:
parent_visited = visited + [parent.ref] parent_visited = visited + [parent.ref]
todo.append((parent_place, parent_visited)) todo.append((parent_place, parent_visited))
return False return False