Skip to content

Commit b6c3eea

Browse files
authored
remove duplicate forecasts in daily/hourly forecast lists (#448)
1 parent 7bfa0cc commit b6c3eea

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

msc_pygeoapi/loader/citypageweather_realtime.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,9 +2645,14 @@ def _set_cpw_forecast_group(self):
26452645
for forecast_func in set_forecast_funcs:
26462646
forecast_dict = forecast_func(forecast_elem, forecast_dict)
26472647

2648-
self.cpw_feature['properties']['forecastGroup'][
2649-
'forecasts'
2650-
].append(forecast_dict)
2648+
try:
2649+
self.cpw_feature['properties']['forecastGroup'][
2650+
'forecasts'
2651+
][i] = forecast_dict
2652+
except IndexError:
2653+
self.cpw_feature['properties']['forecastGroup'][
2654+
'forecasts'
2655+
].insert(i, forecast_dict)
26512656

26522657
if not self.cpw_feature['properties'].get('forecast_group'):
26532658
self.cpw_feature['properties'].pop('forecast_group', None)
@@ -2929,9 +2934,14 @@ def _set_cpw_hourly_forecast_group(self):
29292934
hourly_forecast_elem, hourly_forecast_dict
29302935
)
29312936

2932-
self.cpw_feature['properties']['hourlyForecastGroup'][
2933-
'hourlyForecasts'
2934-
].append(hourly_forecast_dict)
2937+
try:
2938+
self.cpw_feature['properties']['hourlyForecastGroup'][
2939+
'hourlyForecasts'
2940+
][i] = hourly_forecast_dict
2941+
except IndexError:
2942+
self.cpw_feature['properties']['hourlyForecastGroup'][
2943+
'hourlyForecasts'
2944+
].insert(i, hourly_forecast_dict)
29352945

29362946
return self.cpw_feature
29372947

0 commit comments

Comments
 (0)