-
-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial commit * .md added * GUI details added * update_docu_links --------- Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
- Loading branch information
Showing
8 changed files
with
172 additions
and
1 deletion.
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
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
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
64 changes: 64 additions & 0 deletions
64
...om_components/waste_collection_schedule/waste_collection_schedule/source/oldham_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,64 @@ | ||
from datetime import datetime | ||
|
||
import requests | ||
from bs4 import BeautifulSoup | ||
from waste_collection_schedule import Collection # type: ignore[attr-defined] | ||
|
||
TITLE = "Oldham Council" | ||
DESCRIPTION = "Source for Oldham Council." | ||
URL = "https://oldham.gov.uk/" | ||
TEST_CASES = { | ||
"Test_001": {"uprn": 422000125973}, | ||
"Test_002": {"uprn": "422000129104"}, | ||
"Test_003": {"uprn": 422000042299}, | ||
} | ||
ICON_MAP = { | ||
"Brown": "mdi:recycle", | ||
"Green": "mdi:leaf", | ||
"Grey": "mdi:trash-can", | ||
"Blue": "mdi:newspaper", | ||
} | ||
HOW_TO_GET_ARGUMENTS_DESCRIPTION = { | ||
"en": "an easy way to discover your Unique Property Reference Number (UPRN) is by going to https://www.findmyaddress.co.uk/ and entering in your address details.", | ||
} | ||
|
||
PARAM_TRANSLATIONS = { | ||
"en": { | ||
"uprn": "Unique Property Reference Number (UPRN)", | ||
} | ||
} | ||
|
||
PARAM_DESCRIPTIONS = { | ||
"en": { | ||
"uprn": "Unique Property Reference Number (UPRN)", | ||
} | ||
} | ||
|
||
|
||
class Source: | ||
def __init__(self, uprn: str | int): | ||
self._uprn = str(uprn) | ||
|
||
def fetch(self): | ||
s = requests.session() | ||
r = s.get( | ||
f"https://portal.oldham.gov.uk/bincollectiondates/details?uprn={self._uprn}" | ||
) | ||
r.raise_for_status | ||
|
||
soup = BeautifulSoup(r.content, "html.parser") | ||
pickups: list = soup.find_all("table", {"class": "data-table confirmation"}) | ||
|
||
entries: list = [] | ||
for item in pickups: | ||
w: str = item.find("th") | ||
d: str = item.find("td", {"class": "coltwo"}) | ||
entries.append( | ||
Collection( | ||
date=datetime.strptime(d.text.strip(), "%d/%m/%Y").date(), | ||
t=w.text.strip(), | ||
icon=ICON_MAP.get(w.text.strip()), | ||
) | ||
) | ||
|
||
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,31 @@ | ||
# Oldham Council | ||
|
||
Support for schedules provided by [Oldham Council](https://www.oldham.gov.uk/), in the UK. | ||
|
||
## Configuration via configuration.yaml | ||
|
||
```yaml | ||
waste_collection_schedule: | ||
sources: | ||
- name: oldham_gov_uk | ||
args: | ||
uprn: UNIQUE_PROPERTY_REFERENCE_NUMBER | ||
``` | ||
### Configuration Variables | ||
**uprn**<br> | ||
*(string)* | ||
The "Unique Property Reference Number" for your address. You can find it by searching for your address at https://www.findmyaddress.co.uk/. | ||
## Example | ||
```yaml | ||
waste_collection_schedule: | ||
sources: | ||
- name: oldham_gov_uk | ||
args: | ||
uprn: "422000129104" | ||
``` | ||
Oops, something went wrong.