Skip to content

Commit

Permalink
fix: meteo test
Browse files Browse the repository at this point in the history
  • Loading branch information
Katrijne-at-Vito committed Mar 11, 2024
1 parent d0f7161 commit db9d73e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pywig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ def get_meteo(self, field_id: str, key: str, start_date: datetime.date = None, e
:rtype: List
"""
field = self.get_field_details(field_id)
print(field)
if field.meteo and key.lower() in field.meteo:
meteo = list(map(lambda x: MeteoStat(date=x['date'], value=x['value']), field.meteo[key.lower()]))
if start_date:
meteo = [x for x in meteo if start_date <= datetime.datetime.strptime(x.date, "%Y-%m-%d").date()]
if end_date:
meteo = [x for x in meteo if datetime.datetime.strptime(x.date, "%Y-%m-%d").date() <= end_date]
return meteo
elif field.metadata.country == 'Belgium':
elif field.metadata and field.metadata['country'] == 'Belgium':
start_date = start_date.isoformat() if start_date else field.metadata['startDate']
end_date = end_date.isoformat() if end_date else field.metadata['endDate']

Expand Down

0 comments on commit db9d73e

Please sign in to comment.