Skip to content

Commit

Permalink
Add publishing requirements for pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
fermartv committed Jul 17, 2023
1 parent f2d4949 commit 207594c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 22 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
62 changes: 40 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 207594c

Please sign in to comment.