mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 02:04:22 +01:00
generate awido_de services list from SERVICE_MAP
This commit is contained in:
@@ -7,134 +7,172 @@ from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
TITLE = "AWIDO Online"
|
||||
DESCRIPTION = "Source for AWIDO waste collection."
|
||||
URL = "https://www.awido-online.de/"
|
||||
EXTRA_INFO = [
|
||||
|
||||
|
||||
def EXTRA_INFO():
|
||||
return [{"title": s["title"], "url": s["url"]} for s in SERVICE_MAP]
|
||||
|
||||
|
||||
SERVICE_MAP = [
|
||||
{
|
||||
"title": "Abfallwirtschaft Rems-Murr",
|
||||
"url": "https://www.abfallwirtschaft-rems-murr.de/",
|
||||
"service_id": "rmk",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Schweinfurt",
|
||||
"url": "https://www.landkreis-schweinfurt.de",
|
||||
"service_id": "lra-schweinfurt",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Gotha",
|
||||
"url": "https://www.landkreis-gotha.de/",
|
||||
"service_id": "gotha",
|
||||
},
|
||||
{
|
||||
"title": "Zweckverband Abfallwirtschaft Saale-Orla",
|
||||
"url": "https://www.zaso-online.de/",
|
||||
"service_id": "zaso",
|
||||
},
|
||||
{
|
||||
"title": "Gemeinde Unterhaching",
|
||||
"url": "https://www.unterhaching.de/",
|
||||
"service_id": "unterhaching",
|
||||
},
|
||||
{
|
||||
"title": "Stadt Kaufbeuren",
|
||||
"url": "https://www.kaufbeuren.de/",
|
||||
"service_id": "kaufbeuren",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Berchtesgadener Land",
|
||||
"url": "https://www.lra-bgl.de/",
|
||||
"service_id": "bgl",
|
||||
},
|
||||
{
|
||||
"title": "Pullach im Isartal",
|
||||
"url": "https://www.pullach.de/",
|
||||
"service_id": "pullach",
|
||||
},
|
||||
{
|
||||
"title": "AWB Landkreis Fürstenfeldbruck",
|
||||
"url": "https://www.awb-ffb.de/",
|
||||
"service_id": "ffb",
|
||||
},
|
||||
{
|
||||
"title": "Stadt Unterschleißheim",
|
||||
"url": "https://www.unterschleissheim.de/",
|
||||
"service_id": "unterschleissheim",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Tirschenreuth",
|
||||
"url": "https://www.kreis-tir.de/",
|
||||
"service_id": "kreis-tir",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Rosenheim",
|
||||
"url": "https://www.abfall.landkreis-rosenheim.de/",
|
||||
"service_id": "rosenheim",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Tübingen",
|
||||
"url": "https://www.abfall-kreis-tuebingen.de/",
|
||||
"service_id": "tuebingen",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Kronach",
|
||||
"url": "https://www.landkreis-kronach.de/",
|
||||
"service_id": "kronach",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Erding",
|
||||
"url": "https://www.landkreis-erding.de/",
|
||||
"service_id": "erding",
|
||||
},
|
||||
{
|
||||
"title": "Zweckverband München-Südost",
|
||||
"url": "https://www.zvmso.de/",
|
||||
"service_id": "zv-muc-so",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Coburg",
|
||||
"url": "https://www.landkreis-coburg.de/",
|
||||
"service_id": "coburg",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Ansbach",
|
||||
"url": "https://www.landkreis-ansbach.de/",
|
||||
"service_id": "ansbach",
|
||||
},
|
||||
{
|
||||
"title": "AWB Landkreis Bad Dürkheim",
|
||||
"url": "http://awb.kreis-bad-duerkheim.de/",
|
||||
"service_id": "awb-duerkheim",
|
||||
},
|
||||
{
|
||||
"title": "Landratsamt Aichach-Friedberg",
|
||||
"url": "https://lra-aic-fdb.de/",
|
||||
"service_id": "aic-fdb",
|
||||
},
|
||||
{
|
||||
"title": "WGV Recycling GmbH",
|
||||
"url": "https://wgv-quarzbichl.de/",
|
||||
"service_id": "wgv",
|
||||
},
|
||||
{
|
||||
"title": "Neustadt a.d. Waldnaab",
|
||||
"url": "https://www.neustadt.de/",
|
||||
"service_id": "neustadt",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Kelheim",
|
||||
"url": "https://www.landkreis-kelheim.de/",
|
||||
"service_id": "kelheim",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Günzburg",
|
||||
"url": "https://kaw.landkreis-guenzburg.de/",
|
||||
"service_id": "kaw-guenzburg",
|
||||
},
|
||||
{
|
||||
"title": "Stadt Memmingen",
|
||||
"url": "https://umwelt.memmingen.de/",
|
||||
"service_id": "memmingen",
|
||||
},
|
||||
{
|
||||
"title": "Landkreis Südliche Weinstraße",
|
||||
"url": "https://www.suedliche-weinstrasse.de/",
|
||||
"service_id": "eww-suew",
|
||||
},
|
||||
{
|
||||
"title": "Landratsamt Dachau",
|
||||
"url": "https://www.landratsamt-dachau.de/",
|
||||
"service_id": "lra-dah",
|
||||
},
|
||||
{
|
||||
"title": "Landkreisbetriebe Neuburg-Schrobenhausen",
|
||||
"url": "https://www.landkreisbetriebe.de/",
|
||||
"service_id": "landkreisbetriebe",
|
||||
},
|
||||
{
|
||||
"title": "Abfallwirtschaftsbetrieb Landkreis Altenkirchen",
|
||||
"url": "https://www.awb-ak.de/",
|
||||
"service_id": "awb-ak",
|
||||
},
|
||||
{
|
||||
"title": "Abfallwirtschaft Lahn-Dill-Kreises",
|
||||
"url": "https://www.awld.de/",
|
||||
"service_id": "awld",
|
||||
},
|
||||
{
|
||||
"title": "Abfallwirtschafts-Zweckverband des Landkreises Hersfeld-Rotenburg",
|
||||
"url": "https://www.azv-hef-rof.de/",
|
||||
"service_id": "azv-hef-rof",
|
||||
},
|
||||
{
|
||||
"title": "Abfall-Wirtschafts-Verband Nordschwaben",
|
||||
"url": "https://www.awv-nordschwaben.de/",
|
||||
"service_id": "awv-nordschwaben",
|
||||
},
|
||||
]
|
||||
TEST_CASES = {
|
||||
|
||||
@@ -48,38 +48,40 @@ waste_collection_schedule:
|
||||
|
||||
List of customers (2021-07-09):
|
||||
|
||||
- `rmk`: AWG des Rems-Murr-Kreises mbH
|
||||
- `lra-schweinfurt`: Landkreis Schweinfurt
|
||||
- `gotha`: Landkreis Gotha
|
||||
- `zaso`: Zweckverband Abfallwirtschaft Saale-Orla
|
||||
- `unterhaching`: Gemeinde Unterhaching
|
||||
- `kaufbeuren`: Stadt Kaufbeuren
|
||||
<!--Begin of service section-->
|
||||
- `aic-fdb`: Landratsamt Aichach-Friedberg
|
||||
- `ansbach`: Landkreis Ansbach
|
||||
- `awb-ak`: Abfallwirtschaftsbetrieb Landkreis Altenkirchen
|
||||
- `awb-duerkheim`: AWB Landkreis Bad Dürkheim
|
||||
- `awld`: Abfallwirtschaft Lahn-Dill-Kreises
|
||||
- `awv-nordschwaben`: Abfall-Wirtschafts-Verband Nordschwaben
|
||||
- `azv-hef-rof`: Abfallwirtschafts-Zweckverband des Landkreises Hersfeld-Rotenburg
|
||||
- `bgl`: Landkreis Berchtesgadener Land
|
||||
- `pullach`: Pullach im Isartal
|
||||
- `ffb`: Landkreis Fürstenfeldbruck
|
||||
- `unterschleissheim`: Stadt Unterschleißheim
|
||||
- `coburg`: Landkreis Coburg
|
||||
- `erding`: Landkreis Erding
|
||||
- `eww-suew`: Landkreis Südliche Weinstraße
|
||||
- `ffb`: AWB Landkreis Fürstenfeldbruck
|
||||
- `gotha`: Landkreis Gotha
|
||||
- `kaufbeuren`: Stadt Kaufbeuren
|
||||
- `kaw-guenzburg`: Landkreis Günzburg
|
||||
- `kelheim`: Landkreis Kelheim
|
||||
- `kreis-tir`: Landkreis Tirschenreuth
|
||||
- `kronach`: Landkreis Kronach
|
||||
- `landkreisbetriebe`: Landkreisbetriebe Neuburg-Schrobenhausen
|
||||
- `lra-dah`: Landratsamt Dachau
|
||||
- `lra-schweinfurt`: Landkreis Schweinfurt
|
||||
- `memmingen`: Stadt Memmingen
|
||||
- `neustadt`: Neustadt a.d. Waldnaab
|
||||
- `pullach`: Pullach im Isartal
|
||||
- `rmk`: Abfallwirtschaft Rems-Murr
|
||||
- `rosenheim`: Landkreis Rosenheim
|
||||
- `tuebingen`: Landkreis Tübingen
|
||||
- `kronach`: Landkreis Kronach
|
||||
- `erding`: Landkreis Erding
|
||||
- `zv-muc-so`: Zweckverband München-Südost
|
||||
- `coburg`: Landkreis Coburg
|
||||
- `ansbach`: Landkreis Ansbach
|
||||
- `awb-duerkheim`: AWB Landkreis Bad Dürkheim
|
||||
- `aic-fdb`: Landratsamt Aichach-Friedberg
|
||||
- `unterhaching`: Gemeinde Unterhaching
|
||||
- `unterschleissheim`: Stadt Unterschleißheim
|
||||
- `wgv`: WGV Recycling GmbH
|
||||
- `neustadt`: Neustadt a.d. Waldnaab
|
||||
- `kelheim`: Landkreis Kelheim
|
||||
- `kaw-guenzburg`: Landkreis Günzburg
|
||||
- `memmingen`: Stadt Memmingen
|
||||
- `eww-suew`: Landkreis Südliche Weinstraße
|
||||
- `lra-dah`: Landratsamt Dachau
|
||||
- `landkreisbetriebe`: Landkreisbetriebe Neuburg-Schrobenhausen
|
||||
- `awb-ak`: Abfallwirtschaftsbetrieb Landkreis Altenkirchen
|
||||
- `awld`: Abfallwirtschaft des Lahn-Dill-Kreises
|
||||
- `azv-hef-rof`: Abfallwirtschafts-Zweckverband des Landkreises Hersfeld-Rotenburg
|
||||
- `awv-nordschwaben`: Abfall-Wirtschafts-Verband Nordschwaben
|
||||
- `zaso`: Zweckverband Abfallwirtschaft Saale-Orla
|
||||
- `zv-muc-so`: Zweckverband München-Südost
|
||||
<!--End of service section-->
|
||||
|
||||
### city, street, house number
|
||||
|
||||
|
||||
@@ -16,22 +16,13 @@ BLACK_LIST = {"ics", "static", "example"}
|
||||
START_COUNTRY_SECTION = "<!--Begin of country section-->"
|
||||
END_COUNTRY_SECTION = "<!--End of country section-->"
|
||||
|
||||
START_SERVICE_SECTION = "<!--Begin of service section-->"
|
||||
END_SERVICE_SECTION = "<!--End of service section-->"
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Test sources.")
|
||||
args = parser.parse_args()
|
||||
|
||||
# read secrets.yaml
|
||||
secrets = {}
|
||||
try:
|
||||
with open(SECRET_FILENAME) as stream:
|
||||
try:
|
||||
secrets = yaml.safe_load(stream)
|
||||
except yaml.YAMLError as exc:
|
||||
print(exc)
|
||||
except FileNotFoundError:
|
||||
# ignore missing secrets.yaml
|
||||
pass
|
||||
# args = parser.parse_args()
|
||||
|
||||
package_dir = (
|
||||
Path(__file__).resolve().parents[0]
|
||||
@@ -49,12 +40,14 @@ def main():
|
||||
map(lambda x: x.stem, source_dir.glob("*.py")),
|
||||
)
|
||||
|
||||
modules = {}
|
||||
sources = []
|
||||
|
||||
# retrieve all data from sources
|
||||
for f in files:
|
||||
# iterate through all *.py files in waste_collection_schedule/source
|
||||
module = importlib.import_module(f"waste_collection_schedule.source.{f}")
|
||||
modules[f] = module
|
||||
|
||||
title = module.TITLE
|
||||
url = module.URL
|
||||
@@ -81,7 +74,7 @@ def main():
|
||||
# sort into countries
|
||||
country_code_map = make_country_code_map()
|
||||
countries = {}
|
||||
zombies = []
|
||||
orphans = []
|
||||
for s in sources:
|
||||
if s.filename in BLACK_LIST:
|
||||
continue # skip
|
||||
@@ -91,14 +84,16 @@ def main():
|
||||
if code in country_code_map:
|
||||
countries.setdefault(country_code_map[code]["name"], []).append(s)
|
||||
else:
|
||||
zombies.append(s)
|
||||
orphans.append(s)
|
||||
|
||||
update_readme_md(countries)
|
||||
update_info_md(countries)
|
||||
update_awido_de(modules)
|
||||
|
||||
print("Zombies =========================")
|
||||
for z in zombies:
|
||||
print(z)
|
||||
if len(orphans) > 0:
|
||||
print("Orphaned =========================")
|
||||
for o in orphans:
|
||||
print(o)
|
||||
|
||||
|
||||
def beautify_url(url):
|
||||
@@ -166,6 +161,32 @@ def update_info_md(countries):
|
||||
f.write(md)
|
||||
|
||||
|
||||
def update_awido_de(modules):
|
||||
module = modules.get("awido_de")
|
||||
if not module:
|
||||
print("awido_de not found")
|
||||
return
|
||||
services = getattr(module, "SERVICE_MAP", [])
|
||||
|
||||
str = ""
|
||||
for service in sorted(services, key=lambda s:s["service_id"]):
|
||||
str += f'- `{service["service_id"]}`: {service["title"]}\n'
|
||||
|
||||
# read entire file
|
||||
with open("doc/source/awido_de.md") as f:
|
||||
md = f.read()
|
||||
|
||||
# find beginning and end of country section
|
||||
start_pos = md.index(START_SERVICE_SECTION) + len(START_SERVICE_SECTION) + 1
|
||||
end_pos = md.index(END_SERVICE_SECTION)
|
||||
|
||||
md = md[:start_pos] + str + md[end_pos:]
|
||||
|
||||
# write entire file
|
||||
with open("doc/source/awido_de.md", "w") as f:
|
||||
f.write(md)
|
||||
|
||||
|
||||
class SourceInfo:
|
||||
def __init__(self, filename, title, url, country):
|
||||
self._filename = filename
|
||||
|
||||
Reference in New Issue
Block a user