improve stadtreinigung dresden code and docu

This commit is contained in:
mampfes
2022-03-22 20:35:56 +01:00
parent fcdc64389d
commit 57939146a9
2 changed files with 15 additions and 8 deletions

View File

@@ -1,28 +1,28 @@
import datetime
import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
from waste_collection_schedule.service.ICS import ICS
TITLE = "Stadtreinigung Dresden"
DESCRIPTION = "Source for Stadtreinigung Dresden waste collection."
URL = "https://stadtplan.dresden.de/project/cardo3Apps/IDU_DDStadtplan/abfall/ical.ashx"
URL = "https://www.dresden.de/apps_ext/AbfallApp/wastebins?0"
TEST_CASES = {
"Neumarkt 6": {"standort": 80542},
}
class Source:
def __init__(self, standort, asId=None):
def __init__(self, standort):
self._standort = standort
self._ics = ICS()
def fetch(self):
now = datetime.datetime.now().date()
r = requests.get(
URL,
"https://stadtplan.dresden.de/project/cardo3Apps/IDU_DDStadtplan/abfall/ical.ashx",
params={
"STANDORT": self._standort,
"DATUM_VON": now.strftime("%d.%m.%Y"),
@@ -32,7 +32,14 @@ class Source:
dates = self._ics.convert(r.text)
# example: "Leerung Gelbe Tonne, Bio-Tonne"
entries = []
for d in dates:
entries.append(Collection(d[0], d[1]))
if d[1] == "Abfallkalender endet bald":
continue
types = d[1].removeprefix("Leerung ")
for type in types.split(", "):
entries.append(Collection(d[0], type))
return entries

View File

@@ -7,7 +7,7 @@ Add support for schedules provided by [https://www.dresden.de/](https://www.dres
```yaml
waste_collection_schedule:
sources:
- name: stadtreinigung_dresden
- name: stadtreinigung_dresden_de
args:
standort: STANDORT_ID
```
@@ -22,7 +22,7 @@ waste_collection_schedule:
```yaml
waste_collection_schedule:
sources:
- name: stadtreinigung_dresden
- name: stadtreinigung_dresden_de
args:
standort: 80542
```