3333#-------------------------------------------------------------------------
3434def get_location_list (db , place , date = None , lang = '' , hier = PlaceHierType .ADMIN ):
3535 """
36- Return a list of place names and types for display.
36+ Return a list of place names, types, and handles for display.
3737 the list is in order of smallest (most enclosed) to largest place.
3838 The list will match the date, lang and hierarchy type.
3939 """
4040 if date is None :
4141 date = __get_latest_date (place )
4242 visited = [place .handle ]
43- lines = [(__get_name (place , date , lang ), __get_type (place , date ))]
43+ name , abbrs = __get_name (place , date , lang )
44+ lines = [(name , __get_type (place , date ), place .handle , abbrs )]
4445 while True :
4546 handle = None
4647 for placeref in place .get_placeref_list ():
@@ -55,19 +56,26 @@ def get_location_list(db, place, date=None, lang='', hier=PlaceHierType.ADMIN):
5556 if place is None :
5657 break
5758 visited .append (handle )
58- lines .append ((__get_name (place , date , lang ), __get_type (place , date )))
59+ name , abbrs = __get_name (place , date , lang )
60+ lines .append ((name , __get_type (place , date ), place .handle , abbrs ))
5961 return lines
6062
63+
6164def __get_name (place , date , lang ):
65+ """ Gets the name for a given date and language. Returns the str name and
66+ a list of abbreviations (PlaceAbbrevType)
67+ """
6268 endonym = None
6369 for place_name in place .get_names ():
6470 name_date = place_name .get_date_object ()
6571 if name_date .is_empty () or date .match_exact (name_date ):
6672 if place_name .get_language () == lang :
67- return place_name .get_value ()
73+ return place_name .get_value (), place_name . get_abbrevs ()
6874 if endonym is None :
6975 endonym = place_name .get_value ()
70- return endonym if endonym is not None else '?'
76+ abbs = place_name .get_abbrevs ()
77+ return (endonym , abbs ) if endonym is not None else ('?' , [])
78+
7179
7280def __get_type (place , date ):
7381 for place_type in place .get_types ():
@@ -76,6 +84,7 @@ def __get_type(place, date):
7684 return place_type
7785 return PlaceType (PlaceType .UNKNOWN )
7886
87+
7988def __get_latest_date (place ):
8089 latest_date = None
8190 for place_name in place .get_names ():
@@ -103,9 +112,9 @@ def get_main_location(db, place, date=None):
103112 result as a dictionary of place types and names.
104113 """
105114 return dict ([(int (place_type ), name )
106- for name , place_type
107- in get_location_list (db , place , date )
108- if not place_type .is_custom ()])
115+ for name , place_type , dummy_hndl , dummy_abbrs
116+ in get_location_list (db , place , date )
117+ if not place_type .is_custom ()])
109118
110119#-------------------------------------------------------------------------
111120#
0 commit comments