Split stations on comma

This commit is contained in:
Julien Wajsberg 2018-10-13 18:35:00 +02:00
parent 82f2e84243
commit 7a9767ffce

View File

@ -289,13 +289,25 @@ def guess_stations(flats_list, constraint, config):
) )
continue continue
matched_stations = fuzzy_match( # Weboob modules can return several stations in a comma-separated list.
flat_station, flat_stations = flat_station.split(',')
# But some stations containing a comma exist, so let's add the initial
# value to the list of stations to check if there was one.
if len(flat_stations) > 1:
flat_stations.append(flat_station)
matched_stations = []
for tentative_station in flat_stations:
matched_stations += fuzzy_match(
tentative_station,
[x.name for x in opendata["stations"]], [x.name for x in opendata["stations"]],
limit=10, limit=10,
threshold=50 threshold=50
) )
# Keep only one occurrence of each station
matched_stations = list(set(matched_stations))
# Filter out the stations that are obviously too far and not well # Filter out the stations that are obviously too far and not well
# guessed # guessed
good_matched_stations = [] good_matched_stations = []