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,10 +87,11 @@ 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)
parent_tree = tree + [(int(parent_place.get_type()), if parent_place is not None:
parent_place.get_all_names())] parent_tree = tree + [(int(parent_place.get_type()),
parent_visited = visited + [parent.ref] parent_place.get_all_names())]
todo.append((parent_place, parent_tree, parent_visited)) parent_visited = visited + [parent.ref]
todo.append((parent_place, parent_tree, parent_visited))
if len(place.get_placeref_list()) == 0: if len(place.get_placeref_list()) == 0:
locations.append(dict(tree)) locations.append(dict(tree))
return locations return locations
@ -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)
parent_visited = visited + [parent.ref] if parent_place is not None:
todo.append((parent_place, parent_visited)) parent_visited = visited + [parent.ref]
todo.append((parent_place, parent_visited))
return False return False