-
-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #439 from fwinn/master
Add source for Landkreis Forchheim, Germany
- Loading branch information
Showing
4 changed files
with
78 additions
and
0 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
34 changes: 34 additions & 0 deletions
34
.../waste_collection_schedule/waste_collection_schedule/source/abfalltermine_forchheim_de.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,34 @@ | ||
import requests | ||
from waste_collection_schedule import Collection # type: ignore[attr-defined] | ||
from waste_collection_schedule.service.ICS import ICS | ||
|
||
import urllib | ||
|
||
TITLE = "Landkreis Forchheim" | ||
DESCRIPTION = "Source for Landkreis Forchheim" | ||
URL = "https://www.abfalltermine-forchheim.de/" | ||
TEST_CASES = { | ||
"Dormitz": {"city": "Dormitz", "area": "Dormitz"}, | ||
"Rüsselbach": {"city": "Igensdorf", "area": "Oberrüsselbach"}, | ||
"Kellerstraße": {"city": "Forchheim", "area": "Untere Kellerstraße (ab Adenauerallee bis Piastenbrücke)"} | ||
} | ||
|
||
|
||
class Source: | ||
def __init__(self, city, area): | ||
self._city = city | ||
self._area = area | ||
self._ics = ICS() | ||
|
||
def fetch(self): | ||
place = urllib.parse.quote(self._city + " - " + self._area) | ||
r = requests.get( | ||
f"http://www.abfalltermine-forchheim.de/Forchheim/Landkreis/{place}/ics?RESTMUELL=true&RESTMUELL_SINGLE=true&BIO=true&YELLOW_SACK=true&PAPER=true" | ||
) | ||
r.encoding = r.apparent_encoding | ||
dates = self._ics.convert(r.text) | ||
|
||
entries = [] | ||
for d in dates: | ||
entries.append(Collection(d[0], d[1])) | ||
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,42 @@ | ||
# Abfalltermine Forchheim | ||
|
||
Support for Landkreis Forchheim schedules provided by [abfalltermine-forchheim.de](https://www.abfalltermine-forchheim.de/) located in Bavaria, Germany. | ||
|
||
## Configuration via configuration.yaml | ||
|
||
```yaml | ||
waste_collection_schedule: | ||
sources: | ||
- name: abfalltermine_forchheim_de | ||
args: | ||
city: CITY | ||
area: AREA | ||
``` | ||
### Configuration Variables | ||
**city**<br> | ||
*(string) (required)* | ||
**area**<br> | ||
*(string) (required)* | ||
### How to get the source arguments | ||
The arguments can be found on [abfalltermine-forchheim.de](https://www.abfalltermine-forchheim.de/). | ||
Search for your area. Use the part in front of the dash as `city` argument and the part behind it as `area` argument. Do not insert additional spaces. | ||
<br> | ||
|
||
**Examples** | ||
Forchheim - Bamberger Straße (nördlich der Adenauerallee) | ||
|
||
```yaml | ||
city: Forchheim | ||
area: Bamberger Straße (nördlich der Adenauerallee) | ||
``` | ||
<br> | ||
Dormitz - Dormitz | ||
|
||
```yaml | ||
city: Dormitz | ||
area: Dormitz | ||
``` |
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