Fixes London Air parsing error (#97557)

This commit is contained in:
Pedro Lamas 2023-08-01 10:04:30 +01:00 committed by GitHub
parent 7e134a3d44
commit 3f5c0a1285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -218,10 +218,12 @@ def parse_api_response(response):
for authority in AUTHORITIES:
for entry in response["HourlyAirQualityIndex"]["LocalAuthority"]:
if entry["@LocalAuthorityName"] == authority:
if isinstance(entry["Site"], dict):
entry_sites_data = [entry["Site"]]
else:
entry_sites_data = entry["Site"]
entry_sites_data = []
if "Site" in entry:
if isinstance(entry["Site"], dict):
entry_sites_data = [entry["Site"]]
else:
entry_sites_data = entry["Site"]
data[authority] = parse_site(entry_sites_data)

View File

@ -3,6 +3,14 @@
"@GroupName": "London",
"@TimeToLive": "38",
"LocalAuthority": [
{
"@LocalAuthorityCode": "7",
"@LocalAuthorityName": "City of London",
"@LaCentreLatitude": "51.51333",
"@LaCentreLongitude": "-0.088947",
"@LaCentreLatitudeWGS84": "6712603.132989",
"@LaCentreLongitudeWGS84": "-9901.534748"
},
{
"@LocalAuthorityCode": "24",
"@LocalAuthorityName": "Merton",