Skip to content

Commit

Permalink
Fix Bracknell Forest Collections (#3016)
Browse files Browse the repository at this point in the history
* Fix Bracknell Forest Collections

* make collection parsing independent from ICON_MAP

---------

Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
  • Loading branch information
cpressland and 5ila5 authored Nov 15, 2024
1 parent ee0fbd9 commit 3df25c4
Showing 1 changed file with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
}

ICON_MAP = {
"General Waste": "mdi:trash-can",
"Recycling": "mdi:recycle",
"Garden": "mdi:leaf",
"Food": "mdi:food-apple",
"general waste": "mdi:trash-can",
"recycling": "mdi:recycle",
"garden": "mdi:leaf",
"food": "mdi:food-apple",
}


Expand Down Expand Up @@ -73,22 +73,17 @@ def fetch(self):
collection_lookup.raise_for_status()
collections = collection_lookup.json()["response"]["collections"]
entries = []
for waste_type in ICON_MAP.keys():
for collection_entry in collections:
try:
entries.append(
Collection(
date=parser.parse(
next(
collection
for collection in collections
if collection["round"] == waste_type
)["firstDate"]["date"]
).date(),
t=waste_type,
icon=ICON_MAP.get(waste_type),
)
coll_day = parser.parse(collection_entry["firstDate"]["date"]).date()
except KeyError:
continue
entries.append(
Collection(
date=coll_day,
t=collection_entry["round"],
icon=ICON_MAP.get(collection_entry["round"].lower()),
)
except (StopIteration, TypeError):
pass
)

return entries

0 comments on commit 3df25c4

Please sign in to comment.