New Source: Carmarthenshire, Wales (#2680)

* scripts added, test run, docs updated

* reformatting

---------

Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
Co-authored-by: 5ila5 <38183212+5ila5@users.noreply.github.com>
This commit is contained in:
dt215git
2024-09-14 13:33:15 +01:00
committed by GitHub
parent 6414252c6d
commit 4979879189
8 changed files with 193 additions and 1 deletions

View File

@@ -1612,6 +1612,7 @@ If your service provider is not listed, feel free to open a [source request issu
- [Cambridge City Council](/doc/source/cambridge_gov_uk.md) / cambridge.gov.uk
- [Canterbury City Council](/doc/source/canterbury_gov_uk.md) / canterbury.gov.uk
- [Cardiff Council](/doc/source/cardiff_gov_uk.md) / cardiff.gov.uk
- [Carmarthenshire County Council](/doc/source/carmarthenshire_gov_wales.md) / carmarthenshire.gov.wales
- [Central Bedfordshire Council](/doc/source/centralbedfordshire_gov_uk.md) / centralbedfordshire.gov.uk
- [Charnwood](/doc/source/charnwood_gov_uk.md) / charnwood.gov.uk
- [Cherwell District Council](/doc/source/cherwell_gov_uk.md) / cherwell.gov.uk

View File

@@ -10332,6 +10332,12 @@
"default_params": {},
"id": "cardiff_gov_uk"
},
{
"title": "Carmarthenshire County Council",
"module": "carmarthenshire_gov_wales",
"default_params": {},
"id": "carmarthenshire_gov_wales"
},
{
"title": "Central Bedfordshire Council",
"module": "centralbedfordshire_gov_uk",

View File

@@ -15332,6 +15332,29 @@
"uprn": "Eine einfache Möglichkeit, Ihre Unique Property Reference Number (UPRN) zu finden, besteht darin, auf https://www.findmyaddress.co.uk/ zu gehen und Ihre Adressdaten einzugeben."
}
},
"args_carmarthenshire_gov_wales": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. \n\nYou can find your UPRN by visiting https://www.findmyaddress.co.uk/ and entering in your address details.\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/carmarthenshire_gov_wales.md",
"data": {
"calendar_title": "Kalender Titel",
"uprn": "UPRN"
},
"data_description": {
"calendar_title": "Ein lesbarerer oder benutzerfreundlicherer Name für den Müllkalender. Wenn nichts angegeben wird, wird der Name der Quelle verwendet.",
"uprn": "Eine einfache Möglichkeit, Ihre Unique Property Reference Number (UPRN) zu finden, besteht darin, auf https://www.findmyaddress.co.uk/ zu gehen und Ihre Adressdaten einzugeben."
}
},
"reconfigure_carmarthenshire_gov_wales": {
"title": "Quelle Neu Konfigurieren",
"description": "Konfiguriere deinen Service Provider. \n\nYou can find your UPRN by visiting https://www.findmyaddress.co.uk/ and entering in your address details.\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/carmarthenshire_gov_wales.md",
"data": {
"calendar_title": "Kalender Titel",
"uprn": "UPRN"
},
"data_description": {
"uprn": "Eine einfache Möglichkeit, Ihre Unique Property Reference Number (UPRN) zu finden, besteht darin, auf https://www.findmyaddress.co.uk/ zu gehen und Ihre Adressdaten einzugeben."
}
},
"args_ics_spenge_de": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. \n\n- Besuchen Sie https://www.spenge.de/Rathaus-Politik/Allgemeines-Stadtservice/Abfall/Online-Abfall-Kalender/ und wählen Sie Ihre Straße.\n- Wählen Sie `Jahreskalender` und die Müllarten, die Sie sehen möchten (lassen Sie alle nicht angekreuzt, um alle Arten zu erhalten).\n- Klicken Sie mit der rechten Maustaste auf den Link `Export in Kalenderanwendung` und kopieren Sie die Linkaddresse, um die ICAL-URL zu erhalten.\n- Verwenden Sie diesen Link als `url`-Parameter.\n- Ersetzen Sie das Jahr (`vJ=2024`) durch '&#123;%Y&#125;' in der URL.\n- Sie können den `regex`-Parameter auf \"SP (.*): Spenge\" setzen, um bessere Titel zu erhalten.\n\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/spenge_de.md",

View File

@@ -15332,6 +15332,29 @@
"uprn": "An easy way to discover your Unique Property Reference Number (UPRN) is by going to https://www.findmyaddress.co.uk/ and entering in your address details."
}
},
"args_carmarthenshire_gov_wales": {
"title": "Configure Source",
"description": "Configure your service provider. \n\nYou can find your UPRN by visiting https://www.findmyaddress.co.uk/ and entering in your address details.\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/carmarthenshire_gov_wales.md.",
"data": {
"calendar_title": "Calendar Title",
"uprn": "Unique Property Reference Number"
},
"data_description": {
"calendar_title": "A more readable, or user-friendly, name for the waste calendar. If nothing is provided, the name returned by the source will be used.",
"uprn": "Every UK residential property is allocated a Unique Property Reference Number (UPRN). You can find yours by going to https://www.findmyaddress.co.uk/ and entering in your address details."
}
},
"reconfigure_carmarthenshire_gov_wales": {
"title": "Reconfigure Source",
"description": "Configure your service provider. \n\nYou can find your UPRN by visiting https://www.findmyaddress.co.uk/ and entering in your address details.\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/carmarthenshire_gov_wales.md.",
"data": {
"calendar_title": "Calendar Title",
"uprn": "Unique Property Reference Number"
},
"data_description": {
"uprn": "Every UK residential property is allocated a Unique Property Reference Number (UPRN). You can find yours by going to https://www.findmyaddress.co.uk/ and entering in your address details."
}
},
"args_ics_spenge_de": {
"title": "Configure Source",
"description": "Configure your service provider. \n\n- Visit https://www.spenge.de/Rathaus-Politik/Allgemeines-Stadtservice/Abfall/Online-Abfall-Kalender/ and select your Street. \n- Select `Jahreskalender` and the bin types you want to see (leave all unchecked to get all types).\n- Right-click copy link address on the `Export in Kalenderanwendung` link to get a ICAL link.\n- Use this link as `url` parameter.\n- Replace the Year (`vJ=2024`) with '&#123;%Y&#125;' in the URL.\n- You may want to set the `regex` parameter to \"SP (.*): Spenge\" to get better titles.\n\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/spenge_de.md.",

View File

@@ -15318,6 +15318,29 @@
"uprn": "Un modo facile per scoprire il tuo Numero di Riferimento Proprietà Unica (UPRN) è andare su https://www.findmyaddress.co.uk/ e inserire i dettagli del tuo indirizzo."
}
},
"args_carmarthenshire_gov_wales": {
"title": "Configurazione Sorgente",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\nYou can find your UPRN by visiting https://www.findmyaddress.co.uk/ and entering in your address details.\n\nMaggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/carmarthenshire_gov_wales.md.",
"data": {
"calendar_title": "Nome Calendario",
"uprn": "UPRN"
},
"data_description": {
"calendar_title": "Puoi cambiare il nome del calendario della raccolta dei rifiuti, altrimenti di default verra' utilizzato il nome del tuo fornitore di servizi.",
"uprn": "Un modo facile per scoprire il tuo Numero di Riferimento Proprietà Unica (UPRN) è andare su https://www.findmyaddress.co.uk/ e inserire i dettagli del tuo indirizzo."
}
},
"reconfigure_carmarthenshire_gov_wales": {
"title": "Riconfigurazione Sorgente",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\nYou can find your UPRN by visiting https://www.findmyaddress.co.uk/ and entering in your address details.\n\nPer maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/carmarthenshire_gov_wales.md.",
"data": {
"calendar_title": "Nome Calendario",
"uprn": "UPRN"
},
"data_description": {
"uprn": "Un modo facile per scoprire il tuo Numero di Riferimento Proprietà Unica (UPRN) è andare su https://www.findmyaddress.co.uk/ e inserire i dettagli del tuo indirizzo."
}
},
"args_ics_spenge_de": {
"title": "Configurazione Sorgente",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\n- Visit https://www.spenge.de/Rathaus-Politik/Allgemeines-Stadtservice/Abfall/Online-Abfall-Kalender/ and select your Street. \n- Select `Jahreskalender` and the bin types you want to see (leave all unchecked to get all types).\n- Right-click copy link address on the `Export in Kalenderanwendung` link to get a ICAL link.\n- Use this link as `url` parameter.\n- Replace the Year (`vJ=2024`) with '&#123;%Y&#125;' in the URL.\n- You may want to set the `regex` parameter to \"SP (.*): Spenge\" to get better titles.\n\n\nMaggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/spenge_de.md.",

View File

@@ -0,0 +1,84 @@
# import datetime
from datetime import datetime
import requests
from bs4 import BeautifulSoup
from waste_collection_schedule import Collection
TITLE = "Carmarthenshire County Council"
DESCRIPTION = "Source script for carmarthenshire.gov.wales"
URL = "https://www.carmarthenshire.gov.wales/"
COUNTRY = "uk"
TEST_CASES = {
"Test_1": {"uprn": 10009546468},
"Test_2": {"uprn": "100100146591"},
"Test_3": {
"uprn": 10004876405,
},
}
ICON_MAP = {
"BLUE": "mdi:recycle",
"BLACK": "mdi:trash-can",
"GARDEN": "mdi:leaf",
"NAPPY": "mdi:biohazard",
}
REMAP_WASTE = { # Map websire containers to underlying waste types
"BLUE": "BLUE BAG & GREEN FOOD BIN",
"BLACK": "BLACK BAG & GLASS BOX",
"GARDEN": "GARDEN WATE",
"NAPPY": "NAPPY & HYGIENE WASTE",
}
# ### Arguments affecting the configuration GUI ####
HOW_TO_GET_ARGUMENTS_DESCRIPTION = { # Optional dictionary to describe how to get the arguments, will be shown in the GUI configuration form above the input fields, does not need to be translated in all languages
"en": "You can find your UPRN by visiting https://www.findmyaddress.co.uk/ and entering in your address details.",
}
PARAM_DESCRIPTIONS = { # Optional dict to describe the arguments, will be shown in the GUI configuration below the respective input field
"en": {
"uprn": "Every UK residential property is allocated a Unique Property Reference Number (UPRN). You can find yours by going to https://www.findmyaddress.co.uk/ and entering in your address details.",
},
}
PARAM_TRANSLATIONS = { # Optional dict to translate the arguments, will be shown in the GUI configuration form as placeholder text
"en": {
"uprn": "Unique Property Reference Number",
},
}
# ### End of arguments affecting the configuration GUI ####
class Source:
def __init__(
self, uprn: str | int
): # argX correspond to the args dict in the source configuration
self._uprn = str(uprn)
def fetch(self) -> list[Collection]:
s = requests.Session()
response = s.get(
f"https://www.carmarthenshire.gov.wales/umbraco/Surface/SurfaceRecycling/Index/?uprn={self._uprn}&lang=en-GB"
)
response.raise_for_status()
soup = BeautifulSoup(response.text, "html.parser")
containers = soup.findAll("div", {"class": "bin-day-container"})
entries = []
for item in containers:
dates = item.findAll("p", {"class": "font11 text-center"})
entries.append(
Collection(
date=datetime.strptime(
dates[0].text.split(" ")[1].strip(), "%d/%m/%Y"
).date(),
t=REMAP_WASTE.get(item["class"][1].upper()),
icon=ICON_MAP.get(item["class"][1].upper()),
)
)
return entries

View File

@@ -0,0 +1,32 @@
# Cardiff Council
Support for schedules provided by [Carmarthenshire County Council](https://www.carmarthenshire.gov.wales/home/council-services/), serving Carmathenshire, Wales (UK).
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: carmarthenshire_gov_wales
args:
uprn: UPRN
```
### Configuration Variables
**UPRN**
*(string) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: carmarthenshire_gov_wales
args:
uprn: "10009546468"
```
## How to find your `UPRN`
An easy way to discover your Unique Property Reference Number (UPRN) is by going to <https://www.findmyaddress.co.uk/> and entering in your address details.

File diff suppressed because one or more lines are too long