From 51ad0903c274e73059b7333278cab5635067f71f Mon Sep 17 00:00:00 2001 From: AghilasMessara Date: Sat, 9 Sep 2023 02:04:11 +0200 Subject: [PATCH] Adding french city mamirolle source (#1251) * Add mamirolle info source * remove dependency + add next year check + reformatting (@5ila5) --------- Co-authored-by: Aghilas MESSARA --- README.md | 6 ++ .../source/mamirolle_info.py | 67 +++++++++++++++++++ doc/source/mamirolle_info.md | 17 +++++ info.md | 1 + update_docu_links.py | 4 ++ 5 files changed, 95 insertions(+) create mode 100644 custom_components/waste_collection_schedule/waste_collection_schedule/source/mamirolle_info.py create mode 100644 doc/source/mamirolle_info.md diff --git a/README.md b/README.md index d9b33681..cdef1ef5 100644 --- a/README.md +++ b/README.md @@ -254,6 +254,12 @@ Waste collection schedules in the following formats and countries are supported. - [Renosyd](/doc/source/renosyd_dk.md) / renosyd.dk +
+France + +- [Mairie de Mamirolle](/doc/source/mamirolle_info.md) / mamirolle.info +
+
Germany diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/mamirolle_info.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/mamirolle_info.py new file mode 100644 index 00000000..ed40efe7 --- /dev/null +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/mamirolle_info.py @@ -0,0 +1,67 @@ +import datetime + +import requests +from bs4 import BeautifulSoup +from waste_collection_schedule import Collection + +TITLE = "Mairie de Mamirolle" +DESCRIPTION = "Source script for mamirolle.info" +COUNTRY = "fr" +URL = "http://mamirolle.info/" + +TEST_CASES = {"TestSource": {}} + +ICON_MAP = { + "Poubelle grise": "mdi:trash-can", + "Poubelle jaune": "mdi:recycle", +} + +MONTH_NAMES = [ + "janvier", + "février", + "mars", + "avril", + "mai", + "juin", + "juillet", + "août", + "septembre", + "octobre", + "novembre", + "décembre", +] + + +class Source: + def fetch(self): + now = datetime.datetime.now() + # get list of regions and weblinks + page = requests.get(URL) + # A lenient HTML parser is need + soup = BeautifulSoup(page.text.replace("