pax_global_header00006660000000000000000000000064145735771530014533gustar00rootroot0000000000000052 comment=5cde335d147b7d4a597b18097ba1f5cd251e5b8d GidoHakvoort-rova-5cde335/000077500000000000000000000000001457357715300155155ustar00rootroot00000000000000GidoHakvoort-rova-5cde335/.gitignore000066400000000000000000000022631457357715300175100ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ GidoHakvoort-rova-5cde335/LICENSE000066400000000000000000000021111457357715300165150ustar00rootroot00000000000000MIT License Copyright (c) 2022 Gido and synoniem Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. GidoHakvoort-rova-5cde335/README.md000066400000000000000000000015051457357715300167750ustar00rootroot00000000000000# ROVA Wrapper to get ROVA calendar from Rova's API Acces to ROVA API has been simplified since version 0.2.1 of this wrapper Just use https://www.rova.nl/api/waste-calendar/upcoming?postalcode=1000AA&houseNumber=1&addition=&take=5 with a existing combination of postalcode, housenumber, [housenumber addition] take=5 means that five upcoming dates are returned, min is 1 max unknown Be aware that ROVA API has not been officially published by ROVA. ## Create a new connection by supplying your zip code and house number ``` r = rova.Rova(YOUR_ZIP_CODE, YOUR_HOUSE_NUMBER, [YOUR_HOUSE_NUMBER_ADDITION]) ``` ## API Request Check wether ROVA collects garbage at the given zip code and house number and addition ``` def is_rova_area(): ``` This method return the parsed JSON response as a list. ``` def get_calendar_items([TAKE]): ```GidoHakvoort-rova-5cde335/rova/000077500000000000000000000000001457357715300164645ustar00rootroot00000000000000GidoHakvoort-rova-5cde335/rova/__init__.py000066400000000000000000000000431457357715300205720ustar00rootroot00000000000000"""Initialize the rova package.""" GidoHakvoort-rova-5cde335/rova/rova.py000066400000000000000000000056441457357715300200160ustar00rootroot00000000000000""" Wrapper to get ROVA calendar from Rova's API Acces to this ROVA API has been simplified since version 0.2.1 of this wrapper Just use https://www.rova.nl/api/waste-calendar/upcoming?postalcode=1000AA&houseNumber=1&addition=&take=5 with a existing combination of postalcode, housenumber, housenumber addition Be aware that this API has not been officially published by ROVA. """ from datetime import datetime import random import requests __title__ = "rova" __version__ = "0.4.1" __author__ = "Gido Hakvoort and synoniem " __license__ = "MIT" class Rova: """ ROVA class """ def __init__(self, zip_code, house_number, house_addition=""): """ To fetch the garbage calendar, you need to set a zip_code and house_number. """ self.zip_code = zip_code.replace(' ', '') self.house_number = house_number.strip() self.house_addition = house_addition.strip() def is_rova_area(self): """ Check if ROVA collects garbage at this address """ url = 'https://www.rova.nl/api/waste-calendar/upcoming' # request data from rova API and check if garbage is collected at this address # requesting with a non-existing postalcode will result in a error message response = requests.get(url, params={ 'postalcode': self.zip_code, 'houseNumber': self.house_number, 'addition': self.house_addition, 'take': '1', }) response.raise_for_status() rova_response = response.text.strip() if rova_response != '[]': rova_response = "OK" return rova_response == "OK" def get_calendar_items(self, take=5): """ Get next pickup date for each garbage types """ url = 'https://www.rova.nl/api/waste-calendar/upcoming' # request data from rova API and save response first 5 items (default) response = requests.get(url, params={ 'postalcode': self.zip_code, 'houseNumber': self.house_number, 'addition': self.house_addition, 'take': take, }) response.raise_for_status() rova_response = response.json() items = [] types = [] # add next pickup date for each garbage type for item in rova_response: date = datetime.strptime(item["date"], "%Y-%m-%dT%H:%M:%SZ") date = date.strftime("%Y-%m-%dT%H:%M:%S") garbage_type = item["wasteType"]["code"].upper() # Breaking API change, so fix for upstream if garbage_type in {"PAP", "LOSPAP"}: garbage_type = "PAPIER" if garbage_type == "RST": garbage_type = "RESTAFVAL" items.append({ 'GarbageTypeCode': garbage_type, 'Date': date }) types.append(garbage_type) return items GidoHakvoort-rova-5cde335/setup.py000066400000000000000000000011601457357715300172250ustar00rootroot00000000000000import setuptools with open("README.md", "r", encoding='utf-8') as fh: long_description = fh.read() setuptools.setup( name="rova", version="0.4.1", author="Gido Hakvoort", author_email="gido@hakvoort.it", description="API wrapper for ROVA calendar", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/GidoHakvoort/rova", packages=setuptools.find_packages(), classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], )