Skip to content

Commit

Permalink
Quick hack to fix #155 (json str returned by Meteo France is weird)
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier committed Oct 8, 2020
1 parent 8e7b74b commit 5cc30af
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nabweatherd/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def get(self, request, *args, **kwargs):
client = MeteoFranceClient()
list_places = client.search_places(search_location)
for one_place in list_places:
# correct bad json returned my MeteoFrance
one_place.raw_data['name'] = one_place.raw_data['name'].replace("'", " ")
one_place.raw_data['admin'] = one_place.raw_data['admin'].replace("'", " ")
json_item['value'] = str(one_place.raw_data)
json_item['text'] = one_place.__str__()
json_places.append(json_item)
Expand All @@ -52,6 +55,8 @@ def post(self, request, *args, **kwargs):
if (location != ""):
location = location.replace("None", "''")
location = location.replace("\'", "\"")


location_json = json.loads(location)
location_place = Place(location_json)
config.location = location
Expand Down

0 comments on commit 5cc30af

Please sign in to comment.