Skip to content

Commit

Permalink
improve stadtreinigung dresden code and docu
Browse files Browse the repository at this point in the history
  • Loading branch information
mampfes committed Mar 22, 2022
1 parent fcdc643 commit 5793914
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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"),
Expand All @@ -32,7 +32,14 @@ def fetch(self):

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
4 changes: 2 additions & 2 deletions doc/source/stadtreinigung_dresden_de.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -22,7 +22,7 @@ waste_collection_schedule:
```yaml
waste_collection_schedule:
sources:
- name: stadtreinigung_dresden
- name: stadtreinigung_dresden_de
args:
standort: 80542
```
Expand Down

0 comments on commit 5793914

Please sign in to comment.