-
-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* edlitz source added * edlitz.md added * updates * update_docu_links run
- Loading branch information
Showing
4 changed files
with
59 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
46 changes: 46 additions & 0 deletions
46
custom_components/waste_collection_schedule/waste_collection_schedule/source/edlitz_at.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,46 @@ | ||
from datetime import datetime | ||
|
||
import requests | ||
from bs4 import BeautifulSoup | ||
from waste_collection_schedule import Collection # type: ignore[attr-defined] | ||
|
||
TITLE = "Marktgemeinde Edlitz" | ||
DESCRIPTION = "Source for Marktgeneinde Edlitz, AT" | ||
URL = "https://edlitz.at" | ||
TEST_CASES = {"TestSource": {}, "IgnoredArgument": {"_": ""}} | ||
ICON_MAP = { | ||
"Biomüllabfuhr": "mdi:food", | ||
"Papier Tonne": "mdi:newspaper", | ||
"Grüne Tonne": "mdi:recycle", | ||
"Restmüll": "mdi:trash-can", | ||
"Restmüll mit Panoramastraße": "mdi:trash-can", | ||
} | ||
|
||
|
||
class Source: | ||
def __init__(self, _=None): | ||
pass | ||
|
||
def fetch(self): | ||
s = requests.Session() | ||
r = s.get("https://www.edlitz.at/Buergerservice/Muellabfuhrtermine") | ||
|
||
soup = BeautifulSoup(r.text, "html.parser") | ||
td = soup.find_all("td", {"class": "td_kal"}) | ||
|
||
dts = td[::2] | ||
wst = td[1::2] | ||
|
||
entries = [] | ||
for i in range(0, len(dts)): | ||
entries.append( | ||
Collection( | ||
date=datetime.strptime( | ||
dts[i].text.split(" ")[0].strip(), "%d.%m.%Y" | ||
).date(), | ||
t=wst[i].text.strip(), | ||
icon=ICON_MAP.get(wst[i].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,11 @@ | ||
# Marktgemeinde Edlitz | ||
|
||
Support for schedules provided by Marktgemeinde Edlitz, Lower Austria. | ||
|
||
## Configuration via configuration.yaml | ||
|
||
```yaml | ||
waste_collection_schedule: | ||
sources: | ||
- name: edlitz_at | ||
``` |
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