-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
663 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/python | ||
{ | ||
"name": "Python Dev Container", | ||
"image": "mcr.microsoft.com/devcontainers/python:3.12", | ||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
"ghcr.io/devcontainers-extra/features/poetry:2": {}, | ||
"ghcr.io/devcontainers-extra/features/ruff:1": {}, | ||
"ghcr.io/devcontainers/features/git:1": {}, | ||
"ghcr.io/devcontainers/features/github-cli:1": {}, | ||
"ghcr.io/devcontainers/features/python:1": {} | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "poetry install", | ||
// Configure tool-specific properties. | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"charliermarsh.ruff", | ||
"ms-python.python" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Build Package | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install poetry | ||
poetry install | ||
- name: Build the package | ||
run: poetry build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Publish to PyPI | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Install Poetry | ||
run: pip install poetry | ||
|
||
- name: Install dependencies | ||
run: poetry install --no-dev | ||
|
||
- name: Build and Publish | ||
env: | ||
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} | ||
run: poetry publish --build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Lint with Ruff | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install poetry | ||
poetry install | ||
- name: Run Ruff | ||
run: poetry run ruff check . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install poetry | ||
poetry install | ||
- name: Run tests | ||
run: poetry run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,79 @@ | ||
# pyRail | ||
|
||
A Python wrapper for the iRail API | ||
A Python wrapper for the iRail API, designed to make interacting with iRail simple and efficient. | ||
|
||
## Overview | ||
pyRail is a Python library that provides a convenient interface for interacting with the iRail API. It supports various endpoints such as stations, liveboard, vehicle, connections, and disturbances. The library includes features like caching and rate limiting to optimize API usage. | ||
|
||
## Features | ||
- Retrieve real-time train information, including liveboards and vehicle details. | ||
- Access train station data, connections, and disturbances. | ||
- Supports API endpoints: stations, liveboard, vehicle, connections, and disturbances. | ||
- Caching and conditional GET requests using ETags. | ||
- Rate limiting to handle API request limits efficiently. | ||
|
||
## Installation | ||
To install pyRail, use pip: | ||
|
||
```bash | ||
pip install pyrail | ||
``` | ||
|
||
## Usage | ||
Here is an example of how to use pyRail: | ||
|
||
```python | ||
from pyrail.irail import iRail | ||
|
||
# Create an instance of the iRail class | ||
api = iRail(format='json', lang='en') | ||
|
||
# Make a request to the 'stations' endpoint | ||
stations = api.get_stations() | ||
|
||
# Print the response | ||
print(stations) | ||
``` | ||
|
||
## Configuration | ||
You can configure the format and language for the API requests: | ||
|
||
```python | ||
api = iRail(format='json', lang='en') | ||
``` | ||
|
||
- Supported formats: json, xml, jsonp | ||
- Supported languages: nl, fr, en, de | ||
|
||
## Development | ||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/tjorim/pyrail.git | ||
``` | ||
2. Install dependencies using Poetry: | ||
```bash | ||
poetry install | ||
``` | ||
3. Run tests: | ||
```bash | ||
poetry run pytest | ||
``` | ||
|
||
## Logging | ||
You can set the logging level at runtime to get detailed logs: | ||
|
||
```python | ||
import logging | ||
api.set_logging_level(logging.DEBUG) | ||
``` | ||
|
||
## Contributing | ||
Contributions are welcome! Please open an issue or submit a pull request. | ||
|
||
## Contributors | ||
- @tjorim | ||
- @jcoetsie | ||
|
||
## License | ||
This project is licensed under the Apache 2.0 License. See the LICENSE file for details. |
Oops, something went wrong.