Skip to content

Commit

Permalink
add examples for ICS
Browse files Browse the repository at this point in the history
remove them from ICS test-cases and ICS docu
  • Loading branch information
mampfes committed Apr 6, 2023
1 parent 4921f0d commit 14c4ec8
Show file tree
Hide file tree
Showing 39 changed files with 606 additions and 774 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Waste collection schedules in the following formats and countries are supported.
<summary>Belgium</summary>

- [Hygea](/doc/source/hygea_be.md) / hygea.be
- [Limburg.net](/doc/source/ics/limburg_net.md) / limburg.net
- [Recycle!](/doc/source/recycleapp_be.md) / recycleapp.be
</details>

Expand Down Expand Up @@ -121,6 +122,7 @@ Waste collection schedules in the following formats and countries are supported.
- [ART Trier](/doc/source/art_trier_de.md) / art-trier.de
- [ASO Abfall-Service Osterholz](/doc/source/abfall_io.md) / aso-ohz.de
- [ASR Stadt Chemnitz](/doc/source/asr_chemnitz_de.md) / asr-chemnitz.de
- [AVL - Abfallverwertungsgesellschaft des Landkreises Ludwigsburg mbH](/doc/source/ics/avl_ludwigsburg_de.md) / avl-ludwigsburg.de
- [AWA Entsorgungs GmbH](/doc/source/abfallnavi_de.md) / awa-gmbh.de
- [AWB Abfallwirtschaft Vechta](/doc/source/abfallwirtschaft_vechta_de.md) / abfallwirtschaft-vechta.de
- [AWB Bad Kreuznach](/doc/source/awb_bad_kreuznach_de.md) / app.awb-bad-kreuznach.de
Expand All @@ -132,6 +134,7 @@ Waste collection schedules in the following formats and countries are supported.
- [AWB Westerwaldkreis](/doc/source/abfall_io.md) / wab.rlp.de
- [AWG Kreis Warendorf](/doc/source/abfallnavi_de.md) / awg-waf.de
- [AWIDO Online](/doc/source/awido_de.md) / awido-online.de
- [Awista Starnberg](/doc/source/ics/awista_starnberg_de.md) / awista-starnberg.de
- [Bau & Service Oberursel](/doc/source/c_trace_de.md) / bso-oberursel.de
- [Bergischer Abfallwirtschaftverbund](/doc/source/abfallnavi_de.md) / bavweb.de
- [Berlin Recycling](/doc/source/berlin_recycling_de.md) / berlin-recycling.de
Expand All @@ -145,11 +148,15 @@ Waste collection schedules in the following formats and countries are supported.
- [Dillingen Saar](/doc/source/dillingen_saar_de.md) / dillingen-saar.de
- [Dinslaken](/doc/source/abfallnavi_de.md) / dinslaken.de
- [EAD Darmstadt](/doc/source/ead_darmstadt_de.md) / ead.darmstadt.de
- [EDG Entsorgung Dortmund](/doc/source/ics/edg_de.md) / edg.de
- [EGN Abfallkalender](/doc/source/egn_abfallkalender_de.md) / egn-abfallkalender.de
- [EGST Steinfurt](/doc/source/abfall_io.md) / egst.de
- [EGW Westmünsterland](/doc/source/abfallnavi_de.md) / egw.de
- [Entsorgungs- und Wirtschaftsbetrieb Landau in der Pfalz](/doc/source/c_trace_de.md) / ew-landau.de
- [Entsorgungsbetrieb Märkisch-Oderland](/doc/source/ics/entsorgungsbetrieb_mol_de.md) / entsorgungsbetrieb-mol.de
- [Entsorgungsbetriebe Essen](/doc/source/abfall_io.md) / ebe-essen.de
- [Entsorgungsgesellschaft Görlitz-Löbau-Zittau](/doc/source/ics/abfall_eglz_de.md) / abfall-eglz.de
- [FES Frankfurter Entsorgungs- und Service GmbH](/doc/source/ics/fes_frankfurt_de.md) / fes-frankfurt.de
- [Gemeinde Aschheim](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Blankenheim](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Bühlerzell](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
Expand Down Expand Up @@ -205,18 +212,21 @@ Waste collection schedules in the following formats and countries are supported.
- [Landkreis Schwäbisch Hall](/doc/source/lrasha_de.md) / lrasha.de
- [Landkreis Schwäbisch Hall](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Landkreis Sigmaringen](/doc/source/abfall_io.md) / landkreis-sigmaringen.de
- [Landkreis Stade](/doc/source/ics/landkreis_stade_de.md) / landkreis-stade.de
- [Landkreis Südliche Weinstraße](/doc/source/awido_de.md) / suedliche-weinstrasse.de
- [Landkreis Tirschenreuth](/doc/source/awido_de.md) / kreis-tir.de
- [Landkreis Tübingen](/doc/source/awido_de.md) / abfall-kreis-tuebingen.de
- [Landkreis Weißenburg-Gunzenhausen](/doc/source/abfall_io.md) / landkreis-wug.de
- [Landkreis Wittmund](/doc/source/landkreis_wittmund_de.md) / landkreis-wittmund.de
- [Landkreisbetriebe Neuburg-Schrobenhausen](/doc/source/awido_de.md) / landkreisbetriebe.de
- [Landratsamt Aichach-Friedberg](/doc/source/awido_de.md) / lra-aic-fdb.de
- [Landratsamt Bodenseekreis](/doc/source/ics/bodenseekreis_de.md) / bodenseekreis.de
- [Landratsamt Dachau](/doc/source/awido_de.md) / landratsamt-dachau.de
- [Landratsamt Main-Tauber-Kreis](/doc/source/c_trace_de.md) / main-tauber-kreis.de
- [Landratsamt Traunstein](/doc/source/abfall_io.md) / traunstein.com
- [Landratsamt Unterallgäu](/doc/source/abfall_io.md) / landratsamt-unterallgaeu.de
- [Ludwigshafen am Rhein](/doc/source/abfall_io.md) / ludwigshafen.de
- [Lübeck Entsorgungsbetriebe](/doc/source/ics/luebeck_de.md) / luebeck.de
- [MZV Biedenkopf](/doc/source/buergerportal_de.md) / mzv-biedenkopf.de
- [MüllALARM / Schönmackers](/doc/source/abfall_io.md) / schoenmackers.de
- [Müllmax](/doc/source/muellmax_de.md) / muellmax.de
Expand All @@ -231,17 +241,20 @@ Waste collection schedules in the following formats and countries are supported.
- [Stadt Arnsberg](/doc/source/c_trace_de.md) / arnsberg.de
- [Stadt Bayreuth](/doc/source/c_trace_de.md) / bayreuth.de
- [Stadt Cottbus](/doc/source/abfallnavi_de.md) / cottbus.de
- [Stadt Detmold](/doc/source/ics/detmold_de.md) / detmold.de
- [Stadt Dorsten](/doc/source/abfallnavi_de.md) / ebd-dorsten.de
- [Stadt Ehingen](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Stadt Emden](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Stadt Emmendingen](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Stadt Fulda](/doc/source/awido_de.md) / fulda.de
- [Stadt Kaufbeuren](/doc/source/awido_de.md) / kaufbeuren.de
- [Stadt Koblenz](/doc/source/ics/koblenz_de.md) / koblenz.de
- [Stadt Kraichtal](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Stadt Landshut](/doc/source/abfall_io.md) / landshut.de
- [Stadt Memmingen](/doc/source/awido_de.md) / umwelt.memmingen.de
- [Stadt Messstetten](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Stadt Norderstedt](/doc/source/abfallnavi_de.md) / betriebsamt-norderstedt.de
- [Stadt Osnabrück](/doc/source/ics/osnabrueck_de.md) / osnabrueck.de
- [Stadt Overath](/doc/source/c_trace_de.md) / overath.de
- [Stadt Regensburg](/doc/source/awido_de.md) / regensburg.de
- [Stadt Solingen](/doc/source/abfallnavi_de.md) / solingen.de
Expand All @@ -250,6 +263,7 @@ Waste collection schedules in the following formats and countries are supported.
- [Stadtreinigung Dresden](/doc/source/stadtreinigung_dresden_de.md) / dresden.de
- [Stadtreinigung Hamburg](/doc/source/stadtreinigung_hamburg.md) / stadtreinigung.hamburg
- [Stadtreinigung Leipzig](/doc/source/stadtreinigung_leipzig_de.md) / stadtreinigung-leipzig.de
- [Stadtreinigung Leipzig](/doc/source/ics/stadtreinigung_leipzig_de.md) / stadtreinigung-leipzig.de
- [StadtService Brühl](/doc/source/stadtservice_bruehl_de.md) / stadtservice-bruehl.de
- [STL Lüdenscheid](/doc/source/abfallnavi_de.md) / stl-luedenscheid.de
- [Städteservice Raunheim Rüsselsheim](/doc/source/staedteservice_de.md) / staedteservice.de
Expand All @@ -260,6 +274,7 @@ Waste collection schedules in the following formats and countries are supported.
- [WGV Recycling GmbH](/doc/source/awido_de.md) / wgv-quarzbichl.de
- [Wolfsburger Abfallwirtschaft und Straßenreinigung](/doc/source/was_wolfsburg_de.md) / was-wolfsburg.de
- [WZV Kreis Segeberg](/doc/source/c_trace_de.md) / wzv.de
- [ZAH Hildesheim](/doc/source/ics/zah_hildesheim_de.md) / zah-hildesheim.de
- [ZAW Darmstadt-Dieburg](/doc/source/zaw_online_de.md) / zaw-online.de
- [Zweckverband Abfallwirtschaft Kreis Bergstraße](/doc/source/zakb_de.md) / zakb.de
- [Zweckverband Abfallwirtschaft Region Trier (A.R.T.)](/doc/source/ics/art_trier_de.md) / art-trier.de
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@
DESCRIPTION = "Source for ICS based schedules."
URL = None
TEST_CASES = {
"Dortmund, Dudenstr. 5": {
"url": "https://www.edg.de/ical/kalender.ics?Strasse=Dudenstr.&Hausnummer=5&Erinnerung=-1&Abfallart=1,2,3,4"
},
"Leipzig, Sandgrubenweg 27": {
"url": "https://stadtreinigung-leipzig.de/wir-kommen-zu-ihnen/abfallkalender/ical.ics?position_nos=38296&name=Sandgrubenweg%2027"
},
"Ludwigsburg": {
"url": "https://kundenportal.avl-lb.de/WasteManagementLudwigsburg/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=950230001&AboID=8188&Fra=BT;RT;PT;LT;GT"
},
"Esslingen, Bahnhof": {
"url": "https://api.abfall.io/?kh=DaA02103019b46345f1998698563DaAd&t=ics&s=1a862df26f6943997cef90233877a4fe"
},
Expand All @@ -39,9 +30,6 @@
"url": "https://www.awm-muenchen.de/entsorgen/abfuhrkalender?tx_awmabfuhrkalender_abfuhrkalender%5Bhausnummer%5D=11&tx_awmabfuhrkalender_abfuhrkalender%5Bleerungszyklus%5D%5BB%5D=1%2F2%3BU&tx_awmabfuhrkalender_abfuhrkalender%5Bleerungszyklus%5D%5BP%5D=1%2F2%3BG&tx_awmabfuhrkalender_abfuhrkalender%5Bleerungszyklus%5D%5BR%5D=001%3BU&tx_awmabfuhrkalender_abfuhrkalender%5Bsection%5D=ics&tx_awmabfuhrkalender_abfuhrkalender%5Bsinglestandplatz%5D=false&tx_awmabfuhrkalender_abfuhrkalender%5Bstandplatzwahl%5D=true&tx_awmabfuhrkalender_abfuhrkalender%5Bstellplatz%5D%5Bbio%5D=70024507&tx_awmabfuhrkalender_abfuhrkalender%5Bstellplatz%5D%5Bpapier%5D=70024507&tx_awmabfuhrkalender_abfuhrkalender%5Bstellplatz%5D%5Brestmuell%5D=70024507&tx_awmabfuhrkalender_abfuhrkalender%5Bstrasse%5D=bahnstr.&tx_awmabfuhrkalender_abfuhrkalender%5Byear%5D={%Y}",
"version": 1,
},
"Buxtehude, Am Berg": {
"url": "https://abfall.landkreis-stade.de/api_v2/collection_dates/1/ort/10/strasse/90/hausnummern/1/abfallarten/R02-R04-B02-D04-D12-P04-R12-R14-W0-R22-R24-R31/kalender.ics"
},
# "Hausmüllinfo: ASR Chemnitz": {
# "url": "https://asc.hausmuell.info/ics/ics.php",
# "method": "POST",
Expand Down Expand Up @@ -89,23 +77,10 @@
},
"year_field": "year",
},
"Detmold": {
"url": "https://abfuhrkalender.detmold.de/icsmaker.php",
"method": "GET",
"params": {"strid": 338},
"year_field": "year",
},
"EAW Rheingau Taunus": {
"url": "https://www.eaw-rheingau-taunus.de/abfallsammlung/abfuhrtermine/feed.ics?tx_vierwdeaw_garbagecalendarics%5Baction%5D=ics&tx_vierwdeaw_garbagecalendarics%5Bcontroller%5D=GarbageCalendar&tx_vierwdeaw_garbagecalendarics%5Bstreet%5D=38",
"split_at": ",",
},
"Recollect, Ottawa": {
"url": "https://recollect.a.ssl.fastly.net/api/places/BCCDF30E-578B-11E4-AD38-5839C200407A/services/208/events.en.ics",
"split_at": "\\, [and ]*",
},
"Frankfurt am Main, Achenbachstrasse 3": {
"url": "https://www.fes-frankfurt.de/abfallkalender/QWNoZW5iYWNoc3RyLnwzfDYwNTk2.ics"
},
"Erlensee, Am Haspel": {
"url": "https://sperrmuell.erlensee.de/?type=reminder",
"method": "POST",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ def main():
action="store_true",
help="Print exception information and stack trace",
)
parser.add_argument(
"-I", "--ics", action="store_true", help="Test all .yaml file for ICS source"
)
parser.add_argument(
"-y", "--yaml", action="append", help="Test given .yaml file for ICS source"
)
args = parser.parse_args()

# read secrets.yaml
Expand All @@ -53,15 +59,21 @@ def main():
# add module directory to path
site.addsitedir(str(package_dir))

# find all source files for testing
if args.source is not None:
files = args.source
else:
files = filter(
# source file(s) given
source_files = args.source
elif not args.ics and args.yaml is None:
# no ICS yaml files given --> test all source files
source_files = filter(
lambda x: x != "__init__",
map(lambda x: x.stem, source_dir.glob("*.py")),
)
else:
# ICS yaml file(s) given
source_files = []

for f in sorted(files):
for f in sorted(source_files):
# iterate through all *.py files in waste_collection_schedule/source
print(f"Testing source {f} ...")
module = importlib.import_module(f"waste_collection_schedule.source.{f}")
Expand All @@ -80,49 +92,65 @@ def main():
# replace secrets in arguments
replace_secret(secrets, tc)

# create source
try:
source = module.Source(**tc)
result = source.fetch()
count = len(result)
if count > 0:
print(
f" found {bcolors.OKGREEN}{count}{bcolors.ENDC} entries for {name}"
)
else:
print(
f" found {bcolors.WARNING}0{bcolors.ENDC} entries for {name}"
)

# test if source is returning the correct date format
if (
len(
list(
filter(lambda x: type(x.date) is not datetime.date, result)
)
)
> 0
):
print(
f"{bcolors.FAIL} ERROR: source returns invalid date format (datetime.datetime instead of datetime.date?){bcolors.ENDC}"
)

if args.list:
result = (
sorted(result, key=lambda x: x.date) if args.sorted else result
)
for x in result:
icon_str = f" [{x.icon}]" if args.icon else ""
weekday_str = x.date.strftime("%a ") if args.weekday else ""
print(
f" {x.date.isoformat()} {weekday_str}: {x.type}{icon_str}"
)
except KeyboardInterrupt:
exit()
except Exception as exc:
print(f" {name} {bcolors.FAIL}failed{bcolors.ENDC}: {exc}")
if args.traceback:
print(indent(traceback.format_exc(), 4))
test_fetch(module, name, tc, args)

# find all ICS yaml files for testing
ics_yaml_dir = Path(__file__).resolve().parents[4] / "doc" / "ics" / "yaml"
if args.ics:
# test all ICS yaml files
yaml_files = ics_yaml_dir.glob("*.yaml")
elif args.yaml:
# ICS yaml files specified
yaml_files = [Path(ics_yaml_dir, f).with_suffix(".yaml") for f in args.yaml]
elif args.source is None:
# neither source nor ICS yaml files specified --> test all yaml files
yaml_files = ics_yaml_dir.glob("*.yaml")
else:
# source files given --> don't test ICS yaml files
yaml_files = []

# run through all .yaml files for ICS source
module = importlib.import_module("waste_collection_schedule.source.ics")
for f in sorted(yaml_files):
print(f"Testing ICS {f.name}")
with open(f) as stream:
# read yaml file
data = yaml.safe_load(stream)

# run through all test-cases
for name, tc in data["test_cases"].items():
test_fetch(module, name, tc, args)


def test_fetch(module, name, tc, args):
# create source
try:
source = module.Source(**tc)
result = source.fetch()
count = len(result)
if count > 0:
print(f" found {bcolors.OKGREEN}{count}{bcolors.ENDC} entries for {name}")
else:
print(f" found {bcolors.WARNING}0{bcolors.ENDC} entries for {name}")

# test if source is returning the correct date format
if len(list(filter(lambda x: type(x.date) is not datetime.date, result))) > 0:
print(
f"{bcolors.FAIL} ERROR: source returns invalid date format (datetime.datetime instead of datetime.date?){bcolors.ENDC}"
)

if args.list:
result = sorted(result, key=lambda x: x.date) if args.sorted else result
for x in result:
icon_str = f" [{x.icon}]" if args.icon else ""
weekday_str = x.date.strftime("%a ") if args.weekday else ""
print(f" {x.date.isoformat()} {weekday_str}: {x.type}{icon_str}")
except KeyboardInterrupt:
exit()
except Exception as exc:
print(f" {name} {bcolors.FAIL}failed{bcolors.ENDC}: {exc}")
if args.traceback:
print(indent(traceback.format_exc(), 4))


def replace_secret(secrets, d):
Expand Down
22 changes: 22 additions & 0 deletions doc/ics/abfall_eglz_de.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Entsorgungsgesellschaft Görlitz-Löbau-Zittau

Entsorgungsgesellschaft Görlitz-Löbau-Zittau is supported by the generic [ICS](/doc/source/ics.md) source. For all available configuration options, please refer to the source description.


## How to get the configuration arguments

- Goto <https://www.abfall-eglz.de/abfallkalender.html> and select your municipality.
- Right-click on `Entsorgungstermine als iCalendar herunterladen` and copy link address.
- Replace the `url` in the example configuration with this link.

## Examples

### Oppach

```yaml
waste_collection_schedule:
sources:
- name: ics
args:
url: https://www.abfall-eglz.de/abfallkalender.html?ort=Oppach&ortsteil=Ort+Oppach&strasse=&ics=1
```
4 changes: 3 additions & 1 deletion doc/ics/art_trier_de.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Zweckverband Abfallwirtschaft Region Trier (A.R.T.) is supported by the generic
- Scroll down to `JAHRESKALENDER FÜR IHR OUTLOOK, ETC.`
- Set `Wann möchten Sie erinnert werden?` to `Am Abfuhrtag`.
- Click on `> Kalender (ICS) importieren` to get a webcal link.
- Copy this link into the configuration (see example).
- Replace the `url` in the example configuration with this link.

## Examples

Expand All @@ -20,5 +20,7 @@ waste_collection_schedule:
sources:
- name: ics
args:
regex: 'A.R.T. Abfuhrtermin: (.*)'
split_at: ' & '
url: webcal://abfallkalender.art-trier.de/ics-feed/54578_basberg_1-1800.ics
```
22 changes: 22 additions & 0 deletions doc/ics/avl_ludwigsburg_de.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# AVL - Abfallverwertungsgesellschaft des Landkreises Ludwigsburg mbH

AVL - Abfallverwertungsgesellschaft des Landkreises Ludwigsburg mbH is supported by the generic [ICS](/doc/source/ics.md) source. For all available configuration options, please refer to the source description.


## How to get the configuration arguments

- Goto <https://www.avl-ludwigsburg.de/> and select your location.
- Click on `URL ANZEIGEN` to get a webcal link.
- Replace the `url` in the example configuration with this link.

## Examples

### Sandgrubenweg 27

```yaml
waste_collection_schedule:
sources:
- name: ics
args:
url: https://kundenportal.avl-lb.de/WasteManagementLudwigsburg/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=941092001&AboID=76574&Fra=BT;RT;PT;LT;GT
```
22 changes: 22 additions & 0 deletions doc/ics/awista_starnberg_de.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Awista Starnberg

Awista Starnberg is supported by the generic [ICS](/doc/source/ics.md) source. For all available configuration options, please refer to the source description.


## How to get the configuration arguments

- Goto <https://www.awista-starnberg.de/abfallwirtschaftskalender/> and select your municipality.
- Click on `URL in die Zwischenablage kopieren`.
- Replace the `url` in the example configuration with this link.

## Examples

### Berg, Ahornweg 1

```yaml
waste_collection_schedule:
sources:
- name: ics
args:
url: https://xmlcall.awista-starnberg.de/WasteManagementStarnberg/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=162188001&AboID=104609&Fra=P;R;B;S;G
```
Loading

0 comments on commit 14c4ec8

Please sign in to comment.