-
-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Source: Warwick District Council, UK (#1343)
* warwick source, initial commit * .md added * update_docu_links run
- Loading branch information
Showing
6 changed files
with
91 additions
and
3 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
52 changes: 52 additions & 0 deletions
52
...components/waste_collection_schedule/waste_collection_schedule/source/warwickdc_gov_uk.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,52 @@ | ||
from datetime import datetime | ||
|
||
import requests | ||
from bs4 import BeautifulSoup | ||
from waste_collection_schedule import Collection # type: ignore[attr-defined] | ||
|
||
TITLE = "Warwick District Council" | ||
DESCRIPTION = "Source for Warwick District Council rubbish collection." | ||
URL = "https://www.warwickdc.gov.uk" | ||
TEST_CASES = { | ||
"Test_001": {"uprn": "100070260258"}, | ||
"Test_002": {"uprn": "100070258568"}, | ||
"Test_003": {"uprn": 100070263501}, | ||
} | ||
ICON_MAP = { | ||
"FOOD": "mdi:food", | ||
"GARDEN": "mdi:leaf", | ||
"RECYCLING": "mdi:recycle", | ||
"REFUSE": "mdi:trash-can", | ||
} | ||
|
||
|
||
class Source: | ||
def __init__(self, uprn): | ||
self._uprn = str(uprn) | ||
|
||
def fetch(self): | ||
s = requests.Session() | ||
r = s.get( | ||
f"https://estates7.warwickdc.gov.uk/PropertyPortal/Property/Recycling/{self._uprn}" | ||
) | ||
soup = BeautifulSoup(r.text, "html.parser") | ||
|
||
infoboxes = soup.findAll( | ||
"div", {"class": "col-xs-12 text-center waste-dates margin-bottom-15"} | ||
) | ||
|
||
entries = [] | ||
for box in infoboxes: | ||
items = box.findAll("p") | ||
waste_type = items[0].text.strip().split(" ")[0].strip() | ||
dates = [datetime.strptime(d.text, "%d/%m/%Y").date() for d in items[1:]] | ||
for date in dates: | ||
entries.append( | ||
Collection( | ||
date=date, | ||
t=waste_type, | ||
icon=ICON_MAP.get(waste_type.upper()), | ||
) | ||
) | ||
|
||
return entries |
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,35 @@ | ||
# Warwick District Council | ||
|
||
Support for schedules provided by [Warwick District Council](https://www.warwickdc.gov.uk/info/20465/rubbish_waste_and_recycling). | ||
|
||
## Configuration via configuration.yaml | ||
|
||
```yaml | ||
waste_collection_schedule: | ||
sources: | ||
- name: warwickdc_gov_uk | ||
args: | ||
uprn: UNIQUE_PROPERTY_REFERENCE_NUMBER | ||
``` | ||
### Configuration Variables | ||
**uprn** | ||
*(string) (required)* | ||
## Example using UPRN | ||
```yaml | ||
waste_collection_schedule: | ||
sources: | ||
- name: warwickdc_gov_uk | ||
args: | ||
uprn: "100070263501" | ||
``` | ||
## How to find your `UPRN` | ||
|
||
An easy way to find your Unique Property Reference Number (UPRN) is by going to <https://www.findmyaddress.co.uk/> and entering in your address details. | ||
|
||
Alternatively you can inspect the URL on [Warwick District Council](https://www.warwickdc.gov.uk/info/20465/rubbish_waste_and_recycling). Having searched for your collection schedule, your UPRN is the collection of digits at the end of the URL, for example: _https://estates7.warwickdc.gov.uk/PropertyPortal/Property/Recycling/`100070260258`_ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,6 @@ tests: | |
- B318 | ||
- B319 | ||
- B320 | ||
# - B325 | ||
#- B325 | ||
- B602 | ||
- B604 |