-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #480 from skelt0/feat-Add-support-for-Reading-Boro…
…ugh-Council
- Loading branch information
Showing
3 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
uk_bin_collection/uk_bin_collection/councils/ReadingBoroughCouncil.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from uk_bin_collection.uk_bin_collection.common import * | ||
from uk_bin_collection.uk_bin_collection.get_bin_data import \ | ||
AbstractGetBinDataClass | ||
|
||
class CouncilClass(AbstractGetBinDataClass): | ||
""" | ||
Concrete classes have to implement all abstract operations of the | ||
base class. They can also override some operations with a default | ||
implementation. | ||
""" | ||
|
||
def parse_data(self, page: str, **kwargs) -> dict: | ||
|
||
json_result = json.loads(page.text) | ||
|
||
data = {"bins": []} | ||
|
||
for collection in json_result['collections']: | ||
bin_type = collection['service'] | ||
bin_collection = collection['date'] # Date format is 14/12/2023 00:00:00 | ||
|
||
dict_data = { | ||
"type": bin_type.replace(" Collection Service"," Bin"), | ||
"collectionDate": datetime.strptime(bin_collection, "%d/%m/%Y %H:%M:%S").strftime(date_format) | ||
} | ||
|
||
data["bins"].append(dict_data) | ||
|
||
return data |