From 207594c04c43b9bd2a6eebdafb823f6fb9088eac Mon Sep 17 00:00:00 2001 From: FerMartV Date: Mon, 17 Jul 2023 19:03:43 +0200 Subject: [PATCH] Add publishing requirements for pypi --- .pre-commit-config.yaml | 1 + README.md | 62 ++++++++++++++++++++++++++--------------- pyproject.toml | 23 +++++++++++++++ 3 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4bfd637..d3b6446 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - id: check-json + - id: check-toml - repo: https://github.com/psf/black rev: "23.3.0" diff --git a/README.md b/README.md index 8881161..4a66f07 100644 --- a/README.md +++ b/README.md @@ -2,36 +2,54 @@ Python wrapper for the Madrid EMT (Empresa Municipal de Transportes) API, providing easy access to real-time transportation data in Madrid. -## Example code +## Install - import asyncio +Install the package using pip: - from aiohttp import ClientSession +```bash +pip install madrid-emt +``` - from emt_madrid import EMTAPIAuthenticator, EMTAPIBusStop +## Authentication Instructions - EMAIL = "email-from-EMT" - PASSWORD = "password-from-EMT" +To use the EMT Mobilitylabs API you need to register in their [website](https://mobilitylabs.emtmadrid.es/). Once you are registered you will receive a confirmation email to activate your account. It will not work until you have completed all the steps. - STOP_ID = "72" +## Usage +```python +import asyncio - async def fetch_bus_info(): - """Fetches bus information from the EMT API.""" - async with ClientSession() as session: - emt_api_authenticator = EMTAPIAuthenticator(session, EMAIL, PASSWORD) - await emt_api_authenticator.authenticate() - token = emt_api_authenticator.token - emt_api_bus_stop = EMTAPIBusStop(session, token, STOP_ID) - await emt_api_bus_stop.update_stop_info() - await emt_api_bus_stop.update_bus_arrivals() - return emt_api_bus_stop.get_stop_info() +from aiohttp import ClientSession +from emt_madrid import EMTAPIAuthenticator, EMTAPIBusStop - async def main(): - """Main function to execute the code.""" - bus_info = await fetch_bus_info() - print(bus_info) +EMAIL = "email-from-EMT" +PASSWORD = "password-from-EMT" +STOP_ID = "stop-id-from-EMT" # For example: "72" - asyncio.run(main()) + +async def fetch_bus_info(): + """Fetches bus information from the EMT API.""" + async with ClientSession() as session: + emt_api_authenticator = EMTAPIAuthenticator(session, EMAIL, PASSWORD) + await emt_api_authenticator.authenticate() + token = emt_api_authenticator.token + emt_api_bus_stop = EMTAPIBusStop(session, token, STOP_ID) + await emt_api_bus_stop.update_stop_info() + await emt_api_bus_stop.update_bus_arrivals() + return emt_api_bus_stop.get_stop_info() + + +async def main(): + """Main function to execute the code.""" + bus_info = await fetch_bus_info() + print(bus_info) + + +asyncio.run(main()) +``` + +## Attribution + +Thanks to [EMT Madrid MobilityLabs](https://mobilitylabs.emtmadrid.es/) for providing the data and [documentation](https://apidocs.emtmadrid.es/). diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3603f82 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,23 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "emt_madrid" +version = "0.0.1" +description = "Python wrapper for the Madrid EMT (Empresa Municipal de Transportes) API" +readme = "README.md" +requires-python = ">=3.7" +dependencies = [ + "aiohttp >= 3.8.4", + "async-timeout >= 4.0.2" +] +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://github.com/fermartv/EMTMadrid" +"Bug Tracker" = "https://github.com/fermartv/EMTMadrid/issues"