Skip to content

Commit

Permalink
Merge branch 'main' into aiohttp
Browse files Browse the repository at this point in the history
  • Loading branch information
tjorim authored Jan 3, 2025
2 parents 75bb9ee + 0a36922 commit 47c73bf
Show file tree
Hide file tree
Showing 14 changed files with 663 additions and 93 deletions.
27 changes: 27 additions & 0 deletions .devcontainer/devcontainer.json
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"
]
}
}
}
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
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
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
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
28 changes: 28 additions & 0 deletions .github/workflows/ruff-lint.yml
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 .
28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
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
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ __pycache__/
# C extensions
*.so

# Virtual environment
env/
.venv/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
Expand All @@ -24,6 +27,13 @@ var/
.installed.cfg
*.egg

# Pytest cache
.pytest_cache/

# IDE files
.vscode/
.idea/

# 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.
Expand Down
21 changes: 0 additions & 21 deletions .gitlab-ci.yml

This file was deleted.

78 changes: 77 additions & 1 deletion README.md
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.
Loading

0 comments on commit 47c73bf

Please sign in to comment.