siri-lite 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Dhrions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,16 @@
1
+ include README.md
2
+ include LICENSE
3
+ include services.conf
4
+
5
+ exclude .env.example
6
+ exclude .secrets
7
+ exclude .gitleaksignore
8
+ exclude digest.txt
9
+ exclude main.log
10
+ exclude exchange-with-cts.eml
11
+ exclude siri-lite.png
12
+ recursive-exclude node_modules *
13
+ recursive-exclude build *
14
+ prune .gitea
15
+ prune docs
16
+ prune tests
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.4
2
+ Name: siri-lite
3
+ Version: 0.6.0
4
+ Summary: CLI and library to query SIRI-lite public transport APIs
5
+ Author-email: Dhrions <aturing@laposte.net>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/dhrions/siri-lite
8
+ Project-URL: Repository, https://github.com/dhrions/siri-lite
9
+ Project-URL: Issues, https://github.com/dhrions/siri-lite/issues
10
+ Project-URL: Documentation, https://docs.dhrions.fr/dhrions/siri-lite/
11
+ Keywords: siri,siri-lite,transport,real-time,public-transit,cli
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: click>=8.1
26
+ Requires-Dist: requests>=2.32
27
+ Requires-Dist: python-dateutil>=2.9
28
+ Requires-Dist: Flask>=3.1
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=8.3; extra == "dev"
31
+ Requires-Dist: pytest-mock>=3.14; extra == "dev"
32
+ Requires-Dist: responses>=0.25; extra == "dev"
33
+ Requires-Dist: coverage>=7.6; extra == "dev"
34
+ Requires-Dist: python-semantic-release<10,>=9; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ ![SIRI-lite](siri-lite.png)
38
+
39
+ # SIRI-lite
40
+
41
+ Dhrions
42
+ Version 0.5.0, 12/08/2026
43
+
44
+ > Outil Python pour interroger des API de transport en commun compatibles SIRI-lite
45
+
46
+ [Documentation](https://docs.dhrions.fr/dhrions/siri-lite/) · [Issues](https://gitea.dhrions.fr/dhrions/siri-lite/issues)
47
+
48
+ ## ⚡ TL;DR
49
+
50
+ - 🚌 Interroge des API de transport en commun compatibles SIRI-lite pour les prochains passages et le temps restant avant arrivée
51
+ - 🎯 Pour qui : usage personnel, intégrations (ex. Home Assistant)
52
+ - 🚀 `siri-lite stop-monitoring --service CTS --stop-code 43A --token YOUR_TOKEN --print`
53
+
54
+ Le projet fournit :
55
+ - 🖥️ une **CLI** (ligne de commande),
56
+ - 🌐 une **interface web minimale** (Flask),
57
+ - 🔗 une base solide pour des intégrations (ex. Home Assistant).
58
+
59
+ ## 📋 Table des matières
60
+
61
+ - [⚡ TL;DR](#-tldr)
62
+ - [✨ Fonctionnalités principales](#-fonctionnalités-principales)
63
+ - [🚀 Installation rapide](#-installation-rapide)
64
+ - [💻 Utilisation (CLI)](#-utilisation-cli)
65
+ - [📦 Utilisation avec Docker](#-utilisation-avec-docker)
66
+ - [🧪 Tests](#-tests)
67
+ - [🏗️ Architecture](#️-architecture)
68
+ - [📚 Documentation complète](#-documentation-complète)
69
+ - [⚠️ Sécurité](#️-sécurité)
70
+ - [📄 Licence](#-licence)
71
+
72
+ ---
73
+
74
+ ## ✨ Fonctionnalités principales
75
+
76
+ - ⏱️ Récupération du **temps restant avant l'arrivée** d'un véhicule à un arrêt
77
+ - 🚌 Support de plusieurs réseaux (ex. **CTS**, **PRIM / Île-de-France Mobilités**)
78
+ - 📤 Sortie console, fichier JSON ou intégration applicative
79
+ - 📦 Exécution locale ou via **Docker**
80
+ - 📚 Documentation complète générée avec **Antora**
81
+
82
+ ---
83
+
84
+ ## 🚀 Installation rapide
85
+
86
+ ### Environnement Python
87
+
88
+ ```bash
89
+ python3 -m venv venv
90
+ source venv/bin/activate
91
+ pip install -e ".[dev]"
92
+ ```
93
+
94
+ ### Configuration
95
+
96
+ Copier `.env.example` vers `.env` (fichier réellement ignoré par git, contrairement à
97
+ `.env.example` qui n'est qu'un gabarit) et y renseigner les paramètres du service utilisé :
98
+
99
+ ```
100
+ CTS_BASE_API_URL=https://api.cts-strasbourg.eu/
101
+ CTS_AUTH_METH=Basic Auth
102
+ PRIM_BASE_API_URL=https://prim.iledefrance-mobilites.fr/
103
+ PRIM_AUTH_METH=apiKey
104
+ STOP_MONITORING_ENDPOINT=siri/2.0/stop-monitoring?MonitoringRef=
105
+ ```
106
+
107
+ Ces mêmes valeurs peuvent aussi être fournies via `services.conf`, résolu en suivant la
108
+ spec XDG Base Directory (`--config`, puis `$XDG_CONFIG_HOME/siri-lite/`, puis
109
+ `~/.siri-lite/`, puis le répertoire courant) — voir la documentation Antora pour le
110
+ détail. Les tokens, eux, **ne doivent jamais être commités** ; ils se passent via
111
+ `--token` (CLI) ou `{SERVICE}_TOKEN` (interface web, ex. `CTS_TOKEN` ou `PRIM_TOKEN`
112
+ selon le paramètre `?service=`).
113
+
114
+ ---
115
+
116
+ ## 💻 Utilisation (CLI)
117
+
118
+ Exemple avec le service CTS :
119
+
120
+ ```bash
121
+ siri-lite stop-monitoring \
122
+ --service CTS \
123
+ --stop-code 43A \
124
+ --token YOUR_TOKEN \
125
+ --print
126
+ ```
127
+
128
+ Exemple avec PRIM :
129
+
130
+ ```bash
131
+ siri-lite stop-monitoring \
132
+ --service PRIM \
133
+ --stop-code STIF%3AStopPoint%3AQ%3A473921%3A \
134
+ --token YOUR_TOKEN \
135
+ --print
136
+ ```
137
+
138
+ ### Options
139
+
140
+ | Option | Description |
141
+ |---|---|
142
+ | `--service` | Réseau de transport (`CTS` ou `PRIM`) |
143
+ | `--stop-code` | Code de l'arrêt à interroger |
144
+ | `--token` | Token d'authentification de l'API |
145
+ | `--print` | Affiche le résultat sur la sortie standard |
146
+ | `--unit` | Unité du temps restant (`minutes` ou `seconds`, défaut `minutes`) |
147
+ | `-c`, `--count` | Nombre de prochains passages à afficher (défaut `1` : un entier ; au-delà, une liste) |
148
+ | `-o`, `--output` | Écrit le résultat au format JSON dans le fichier indiqué |
149
+ | `--config` | Chemin explicite vers `services.conf` (voir section Configuration ci-dessus) |
150
+ | `-d`, `--debug` | Active les logs de debug |
151
+
152
+ ---
153
+
154
+ ## 📦 Utilisation avec Docker
155
+
156
+ ```bash
157
+ docker build -t siri-lite .
158
+ docker run --env-file .env siri-lite stop-monitoring \
159
+ --service CTS \
160
+ --stop-code 43A \
161
+ --token YOUR_TOKEN
162
+ ```
163
+
164
+ ---
165
+
166
+ ## 🧪 Tests
167
+
168
+ ```bash
169
+ # Tous les tests
170
+ pytest tests/
171
+
172
+ # Un fichier spécifique
173
+ pytest tests/test_models.py
174
+
175
+ # Avec couverture
176
+ coverage run -m pytest tests/ && coverage report
177
+ ```
178
+
179
+ ---
180
+
181
+ ## 🏗️ Architecture
182
+
183
+ Structure plate et simple :
184
+
185
+ ```
186
+ src/siri_lite/
187
+ ├── cli.py # Commandes CLI (Click)
188
+ ├── web.py # Interface web (Flask)
189
+ ├── services.py # Logique métier
190
+ ├── siri_client.py # Client API SIRI + parsing
191
+ ├── models.py # Modèles de données (DTOs)
192
+ ├── http_client.py # Client HTTP générique (requests)
193
+ ├── config.py # Chargement configuration
194
+ ├── main.py # Point d'entrée
195
+ └── logging_config.py # Configuration du logging
196
+ ```
197
+
198
+ ---
199
+
200
+ ## 📚 Documentation complète
201
+
202
+ La **documentation détaillée** (architecture, services supportés, exemples, intégration Home Assistant, etc.) est disponible via **Antora** :
203
+
204
+ ```bash
205
+ antora antora-playbook.yml
206
+ ```
207
+
208
+ Sources de la documentation : `docs/`
209
+
210
+ ---
211
+
212
+ ## ⚠️ Sécurité
213
+
214
+ - Les fichiers `.env` et `.secrets` **ne doivent jamais être versionnés**
215
+ - Les tokens visibles dans l'historique doivent être considérés comme compromis et régénérés
216
+
217
+ ---
218
+
219
+ ## 📄 Licence
220
+
221
+ Projet personnel – licence à définir.
@@ -0,0 +1,185 @@
1
+ ![SIRI-lite](siri-lite.png)
2
+
3
+ # SIRI-lite
4
+
5
+ Dhrions
6
+ Version 0.5.0, 12/08/2026
7
+
8
+ > Outil Python pour interroger des API de transport en commun compatibles SIRI-lite
9
+
10
+ [Documentation](https://docs.dhrions.fr/dhrions/siri-lite/) · [Issues](https://gitea.dhrions.fr/dhrions/siri-lite/issues)
11
+
12
+ ## ⚡ TL;DR
13
+
14
+ - 🚌 Interroge des API de transport en commun compatibles SIRI-lite pour les prochains passages et le temps restant avant arrivée
15
+ - 🎯 Pour qui : usage personnel, intégrations (ex. Home Assistant)
16
+ - 🚀 `siri-lite stop-monitoring --service CTS --stop-code 43A --token YOUR_TOKEN --print`
17
+
18
+ Le projet fournit :
19
+ - 🖥️ une **CLI** (ligne de commande),
20
+ - 🌐 une **interface web minimale** (Flask),
21
+ - 🔗 une base solide pour des intégrations (ex. Home Assistant).
22
+
23
+ ## 📋 Table des matières
24
+
25
+ - [⚡ TL;DR](#-tldr)
26
+ - [✨ Fonctionnalités principales](#-fonctionnalités-principales)
27
+ - [🚀 Installation rapide](#-installation-rapide)
28
+ - [💻 Utilisation (CLI)](#-utilisation-cli)
29
+ - [📦 Utilisation avec Docker](#-utilisation-avec-docker)
30
+ - [🧪 Tests](#-tests)
31
+ - [🏗️ Architecture](#️-architecture)
32
+ - [📚 Documentation complète](#-documentation-complète)
33
+ - [⚠️ Sécurité](#️-sécurité)
34
+ - [📄 Licence](#-licence)
35
+
36
+ ---
37
+
38
+ ## ✨ Fonctionnalités principales
39
+
40
+ - ⏱️ Récupération du **temps restant avant l'arrivée** d'un véhicule à un arrêt
41
+ - 🚌 Support de plusieurs réseaux (ex. **CTS**, **PRIM / Île-de-France Mobilités**)
42
+ - 📤 Sortie console, fichier JSON ou intégration applicative
43
+ - 📦 Exécution locale ou via **Docker**
44
+ - 📚 Documentation complète générée avec **Antora**
45
+
46
+ ---
47
+
48
+ ## 🚀 Installation rapide
49
+
50
+ ### Environnement Python
51
+
52
+ ```bash
53
+ python3 -m venv venv
54
+ source venv/bin/activate
55
+ pip install -e ".[dev]"
56
+ ```
57
+
58
+ ### Configuration
59
+
60
+ Copier `.env.example` vers `.env` (fichier réellement ignoré par git, contrairement à
61
+ `.env.example` qui n'est qu'un gabarit) et y renseigner les paramètres du service utilisé :
62
+
63
+ ```
64
+ CTS_BASE_API_URL=https://api.cts-strasbourg.eu/
65
+ CTS_AUTH_METH=Basic Auth
66
+ PRIM_BASE_API_URL=https://prim.iledefrance-mobilites.fr/
67
+ PRIM_AUTH_METH=apiKey
68
+ STOP_MONITORING_ENDPOINT=siri/2.0/stop-monitoring?MonitoringRef=
69
+ ```
70
+
71
+ Ces mêmes valeurs peuvent aussi être fournies via `services.conf`, résolu en suivant la
72
+ spec XDG Base Directory (`--config`, puis `$XDG_CONFIG_HOME/siri-lite/`, puis
73
+ `~/.siri-lite/`, puis le répertoire courant) — voir la documentation Antora pour le
74
+ détail. Les tokens, eux, **ne doivent jamais être commités** ; ils se passent via
75
+ `--token` (CLI) ou `{SERVICE}_TOKEN` (interface web, ex. `CTS_TOKEN` ou `PRIM_TOKEN`
76
+ selon le paramètre `?service=`).
77
+
78
+ ---
79
+
80
+ ## 💻 Utilisation (CLI)
81
+
82
+ Exemple avec le service CTS :
83
+
84
+ ```bash
85
+ siri-lite stop-monitoring \
86
+ --service CTS \
87
+ --stop-code 43A \
88
+ --token YOUR_TOKEN \
89
+ --print
90
+ ```
91
+
92
+ Exemple avec PRIM :
93
+
94
+ ```bash
95
+ siri-lite stop-monitoring \
96
+ --service PRIM \
97
+ --stop-code STIF%3AStopPoint%3AQ%3A473921%3A \
98
+ --token YOUR_TOKEN \
99
+ --print
100
+ ```
101
+
102
+ ### Options
103
+
104
+ | Option | Description |
105
+ |---|---|
106
+ | `--service` | Réseau de transport (`CTS` ou `PRIM`) |
107
+ | `--stop-code` | Code de l'arrêt à interroger |
108
+ | `--token` | Token d'authentification de l'API |
109
+ | `--print` | Affiche le résultat sur la sortie standard |
110
+ | `--unit` | Unité du temps restant (`minutes` ou `seconds`, défaut `minutes`) |
111
+ | `-c`, `--count` | Nombre de prochains passages à afficher (défaut `1` : un entier ; au-delà, une liste) |
112
+ | `-o`, `--output` | Écrit le résultat au format JSON dans le fichier indiqué |
113
+ | `--config` | Chemin explicite vers `services.conf` (voir section Configuration ci-dessus) |
114
+ | `-d`, `--debug` | Active les logs de debug |
115
+
116
+ ---
117
+
118
+ ## 📦 Utilisation avec Docker
119
+
120
+ ```bash
121
+ docker build -t siri-lite .
122
+ docker run --env-file .env siri-lite stop-monitoring \
123
+ --service CTS \
124
+ --stop-code 43A \
125
+ --token YOUR_TOKEN
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 🧪 Tests
131
+
132
+ ```bash
133
+ # Tous les tests
134
+ pytest tests/
135
+
136
+ # Un fichier spécifique
137
+ pytest tests/test_models.py
138
+
139
+ # Avec couverture
140
+ coverage run -m pytest tests/ && coverage report
141
+ ```
142
+
143
+ ---
144
+
145
+ ## 🏗️ Architecture
146
+
147
+ Structure plate et simple :
148
+
149
+ ```
150
+ src/siri_lite/
151
+ ├── cli.py # Commandes CLI (Click)
152
+ ├── web.py # Interface web (Flask)
153
+ ├── services.py # Logique métier
154
+ ├── siri_client.py # Client API SIRI + parsing
155
+ ├── models.py # Modèles de données (DTOs)
156
+ ├── http_client.py # Client HTTP générique (requests)
157
+ ├── config.py # Chargement configuration
158
+ ├── main.py # Point d'entrée
159
+ └── logging_config.py # Configuration du logging
160
+ ```
161
+
162
+ ---
163
+
164
+ ## 📚 Documentation complète
165
+
166
+ La **documentation détaillée** (architecture, services supportés, exemples, intégration Home Assistant, etc.) est disponible via **Antora** :
167
+
168
+ ```bash
169
+ antora antora-playbook.yml
170
+ ```
171
+
172
+ Sources de la documentation : `docs/`
173
+
174
+ ---
175
+
176
+ ## ⚠️ Sécurité
177
+
178
+ - Les fichiers `.env` et `.secrets` **ne doivent jamais être versionnés**
179
+ - Les tokens visibles dans l'historique doivent être considérés comme compromis et régénérés
180
+
181
+ ---
182
+
183
+ ## 📄 Licence
184
+
185
+ Projet personnel – licence à définir.
@@ -0,0 +1,83 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "siri-lite"
7
+ version = "0.6.0"
8
+ description = "CLI and library to query SIRI-lite public transport APIs"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+
13
+ authors = [
14
+ { name = "Dhrions", email = "aturing@laposte.net" }
15
+ ]
16
+ keywords = ["siri", "siri-lite", "transport", "real-time", "public-transit", "cli"]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Operating System :: OS Independent",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Topic :: Software Development :: Libraries :: Python Modules",
28
+ ]
29
+
30
+ dependencies = [
31
+ "click>=8.1",
32
+ "requests>=2.32",
33
+ "python-dateutil>=2.9",
34
+ "Flask>=3.1",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "pytest>=8.3",
40
+ "pytest-mock>=3.14",
41
+ "responses>=0.25",
42
+ "coverage>=7.6",
43
+ "python-semantic-release>=9,<10",
44
+ ]
45
+
46
+ [project.scripts]
47
+ siri-lite = "siri_lite.cli:cli"
48
+
49
+ [project.urls]
50
+ Homepage = "https://github.com/dhrions/siri-lite"
51
+ Repository = "https://github.com/dhrions/siri-lite"
52
+ Issues = "https://github.com/dhrions/siri-lite/issues"
53
+ Documentation = "https://docs.dhrions.fr/dhrions/siri-lite/"
54
+
55
+ [tool.setuptools]
56
+ package-dir = { "" = "src" }
57
+ packages = ["siri_lite"]
58
+
59
+ [tool.semantic_release]
60
+ version_toml = ["pyproject.toml:project.version"]
61
+ version_variables = ["src/siri_lite/__init__.py:__version__"]
62
+ branch = "master"
63
+ # Les commits de ce dépôt sont en gitmoji (`✨ feat(cli): …`). Le parser "angular" ne
64
+ # sait pas lire un en-tête préfixé d'un emoji : aucun bump détecté, aucune erreur
65
+ # remontée, la release passe au vert sans rien faire. Voir
66
+ # repos-meta/SEMANTIC_RELEASE_ALIGNMENT.md.
67
+ commit_parser = "emoji"
68
+ major_on_zero = false
69
+ tag_format = "v{version}"
70
+ # [skip ci] : évite que le commit de release redéclenche un run.
71
+ commit_message = "🔖 chore(release): {version} [skip ci]"
72
+
73
+ [tool.semantic_release.commit_parser_options]
74
+ major_tags = ["💥"]
75
+ minor_tags = ["✨"]
76
+ patch_tags = ["🐛", "🚑", "⚡", "🔒"]
77
+
78
+ [tool.semantic_release.changelog]
79
+ exclude_commit_patterns = []
80
+
81
+ [tool.semantic_release.branches.master]
82
+ match = "master"
83
+ prerelease = false
@@ -0,0 +1,12 @@
1
+ # Configuration des services SIRI-lite
2
+
3
+ [CTS]
4
+ base_url = https://api.cts-strasbourg.eu/v1/siri/2.0/
5
+ auth_method = Basic Auth
6
+
7
+ [PRIM]
8
+ base_url = https://prim.iledefrance-mobilites.fr/marketplace/
9
+ auth_method = apiKey
10
+
11
+ [endpoints]
12
+ stop_monitoring = stop-monitoring?MonitoringRef=
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """SIRI-lite - CLI and library to query SIRI-lite public transport APIs."""
2
+
3
+ __version__ = "0.6.0"
@@ -0,0 +1,65 @@
1
+ """Command-line interface."""
2
+
3
+ import json
4
+ import logging
5
+ import click
6
+ import requests
7
+
8
+ from siri_lite import __version__
9
+ from siri_lite.config import load_env, get_stop_monitoring_endpoint
10
+ from siri_lite.siri_client import SiriClient
11
+ from siri_lite.services import get_remaining_times
12
+
13
+ logger = logging.getLogger("main")
14
+
15
+
16
+ @click.group()
17
+ @click.version_option(version=__version__, prog_name="siri-lite")
18
+ def cli():
19
+ """SIRI-lite CLI for public transport information."""
20
+ pass
21
+
22
+
23
+ @cli.command()
24
+ @click.option("--service", type=click.Choice(["CTS", "PRIM"]), required=True)
25
+ @click.option("--stop-code", required=True)
26
+ @click.option("--token", required=True)
27
+ @click.option("--print", "do_print", is_flag=True)
28
+ @click.option("--unit", type=click.Choice(["minutes", "seconds"]), default="minutes")
29
+ @click.option("-c", "--count", type=click.IntRange(min=1), default=1,
30
+ help="Number of upcoming passages to display.")
31
+ @click.option("-o", "--output", type=click.Path())
32
+ @click.option("-d", "--debug", is_flag=True)
33
+ @click.option("--config", type=click.Path(), default=None,
34
+ help="Path to services.conf (default: $XDG_CONFIG_HOME/siri-lite/services.conf).")
35
+ def stop_monitoring(service, stop_code, token, do_print, unit, count, output, debug, config):
36
+ """Display the remaining time for a given stop code."""
37
+ logger.setLevel(logging.DEBUG if debug else logging.INFO)
38
+
39
+ try:
40
+ base_api_url, headers, auth = load_env(service, token, config_path=config)
41
+
42
+ endpoint = get_stop_monitoring_endpoint(config_path=config)
43
+ url = base_api_url + endpoint + stop_code
44
+
45
+ siri_client = SiriClient(url=url, headers=headers, auth=auth)
46
+ remaining_times = get_remaining_times(siri_client, count=count, unit=unit)
47
+ except (ValueError, requests.exceptions.RequestException) as error:
48
+ click.echo(f"❌ {error}", err=True)
49
+ raise SystemExit(1) from error
50
+
51
+ if not remaining_times:
52
+ click.echo("⚠️ Aucun passage disponible pour le moment.")
53
+ return None
54
+
55
+ result = remaining_times[0] if count == 1 else remaining_times
56
+
57
+ if output:
58
+ with open(output, "w") as file:
59
+ json.dump(result, file, indent=4)
60
+ click.echo(f"✅ Résultat écrit dans {output}")
61
+
62
+ if do_print:
63
+ click.echo(result)
64
+
65
+ return result