vigicrues-client 0.2.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.
- vigicrues_client-0.2.0/LICENSE +21 -0
- vigicrues_client-0.2.0/PKG-INFO +184 -0
- vigicrues_client-0.2.0/README.md +154 -0
- vigicrues_client-0.2.0/pyproject.toml +126 -0
- vigicrues_client-0.2.0/pyproject.toml.orig +116 -0
- vigicrues_client-0.2.0/src/vigicrues_client/__init__.py +57 -0
- vigicrues_client-0.2.0/src/vigicrues_client/_bulletins.py +135 -0
- vigicrues_client-0.2.0/src/vigicrues_client/_client.py +435 -0
- vigicrues_client-0.2.0/src/vigicrues_client/_errors.py +54 -0
- vigicrues_client-0.2.0/src/vigicrues_client/_models.py +279 -0
- vigicrues_client-0.2.0/src/vigicrues_client/_observations.py +33 -0
- vigicrues_client-0.2.0/src/vigicrues_client/_payload.py +68 -0
- vigicrues_client-0.2.0/src/vigicrues_client/_referential.py +59 -0
- vigicrues_client-0.2.0/src/vigicrues_client/_stations.py +46 -0
- vigicrues_client-0.2.0/src/vigicrues_client/_time.py +25 -0
- vigicrues_client-0.2.0/src/vigicrues_client/_vigilance.py +29 -0
- vigicrues_client-0.2.0/src/vigicrues_client/py.typed +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mathieu Cartoixa
|
|
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,184 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vigicrues-client
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Asynchronous Python client for Vigicrues, the French flood vigilance service
|
|
5
|
+
Keywords: vigicrues,flood,hydrology,france,asyncio
|
|
6
|
+
Author: Mathieu Cartoixa
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Framework :: AsyncIO
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Hydrology
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Dist: aiohttp>=3.9
|
|
23
|
+
Requires-Dist: beautifulsoup4>=4.13.1
|
|
24
|
+
Requires-Dist: tzdata>=2025.2
|
|
25
|
+
Requires-Python: >=3.11
|
|
26
|
+
Project-URL: Repository, https://github.com/mcartoixa/vigicrues-client
|
|
27
|
+
Project-URL: Issues, https://github.com/mcartoixa/vigicrues-client/issues
|
|
28
|
+
Project-URL: Changelog, https://github.com/mcartoixa/vigicrues-client/releases
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# vigicrues-client
|
|
32
|
+
[](https://pypi.org/project/vigicrues-client/)
|
|
33
|
+
[](https://pypi.org/project/vigicrues-client/)
|
|
34
|
+
[](https://github.com/mcartoixa/vigicrues-client/blob/main/LICENSE)
|
|
35
|
+
[](https://github.com/mcartoixa/vigicrues-client/actions/workflows/build.yml)
|
|
36
|
+
[](https://app.codecov.io/gh/mcartoixa/vigicrues-client)
|
|
37
|
+
|
|
38
|
+
Asynchronous Python client for [Vigicrues](https://www.vigicrues.gouv.fr/), the French flood
|
|
39
|
+
vigilance service: water heights and flow rates observed at the hydrometric stations, flood vigilance
|
|
40
|
+
levels and bulletins of the river sections.
|
|
41
|
+
|
|
42
|
+
This project is not affiliated with Vigicrues. It reads the services and pages of the Vigicrues web
|
|
43
|
+
site, which are not documented as a public API: they may change without notice.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
Requires Python 3.11 or later.
|
|
48
|
+
|
|
49
|
+
```powershell
|
|
50
|
+
pip install vigicrues-client
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
import asyncio
|
|
57
|
+
|
|
58
|
+
from vigicrues_client import Quantity, VigicruesClient, VigilanceLevel
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
async def main() -> None:
|
|
62
|
+
async with VigicruesClient() as client:
|
|
63
|
+
# Water heights observed at a station, in metres
|
|
64
|
+
heights = await client.get_observations("O262002001")
|
|
65
|
+
if heights.latest is not None:
|
|
66
|
+
print(f"{heights.station_name}: {heights.latest.value} m")
|
|
67
|
+
|
|
68
|
+
# Flow rates, in cubic metres per second
|
|
69
|
+
flows = await client.get_observations("E540031001", Quantity.FLOW)
|
|
70
|
+
if flows.latest is not None:
|
|
71
|
+
print(f"{flows.station_name}: {flows.latest.value} m³/s")
|
|
72
|
+
|
|
73
|
+
# Flood vigilance of a river section: level and forecaster's comments
|
|
74
|
+
vigilance = await client.get_river_section_vigilance("MP18")
|
|
75
|
+
print(f"{vigilance.section.name}: {vigilance.level.name}")
|
|
76
|
+
for comment in vigilance.comments:
|
|
77
|
+
print(comment)
|
|
78
|
+
print(vigilance.bulletin.general_comment)
|
|
79
|
+
|
|
80
|
+
# Levels of all the river sections of metropolitan France at once
|
|
81
|
+
levels = await client.get_vigilance_levels()
|
|
82
|
+
in_vigilance = [
|
|
83
|
+
code
|
|
84
|
+
for code, level in levels.levels.items()
|
|
85
|
+
if level >= VigilanceLevel.YELLOW
|
|
86
|
+
]
|
|
87
|
+
print(f"In vigilance at {levels.time}: {in_vigilance}")
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
asyncio.run(main())
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
| Method | Returns |
|
|
94
|
+
|---|---|
|
|
95
|
+
| `get_observations(station, quantity)` | Recent heights or flow rates observed at a station |
|
|
96
|
+
| `get_station(station)` | Details of a station: river, territory, historical floods, stations of the basin |
|
|
97
|
+
| `get_territory(territory)` | A flood vigilance territory and its river sections |
|
|
98
|
+
| `get_river_section(section)` | A river section, its territory and its stations |
|
|
99
|
+
| `get_vigilance_levels()` | Vigilance levels of all the river sections of metropolitan France |
|
|
100
|
+
| `get_vigilance_level(section)` | Vigilance level of a river section |
|
|
101
|
+
| `get_territory_bulletin(territory)` | Vigilance bulletin of a territory: situation, comments, levels of the river sections |
|
|
102
|
+
| `get_river_section_vigilance(section)` | Vigilance level and comments of a river section, with the bulletin of its territory |
|
|
103
|
+
|
|
104
|
+
The bulletins are read from the HTML pages of the Vigicrues web site, and are the most likely to break
|
|
105
|
+
when the site changes.
|
|
106
|
+
|
|
107
|
+
### HTTP session
|
|
108
|
+
|
|
109
|
+
By default, the client creates its own [aiohttp](https://docs.aiohttp.org/) session and closes it
|
|
110
|
+
with the client. An application can pass its own session instead, which the client never closes:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
async with aiohttp.ClientSession() as session:
|
|
114
|
+
client = VigicruesClient(session)
|
|
115
|
+
series = await client.get_observations("O262002001")
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Errors
|
|
119
|
+
|
|
120
|
+
All the errors derive from `VigicruesError`:
|
|
121
|
+
|
|
122
|
+
| Error | Raised when |
|
|
123
|
+
|---|---|
|
|
124
|
+
| `VigicruesConnectionError` | The service could not be reached or did not answer in time (`timeout` argument of the client, in seconds) |
|
|
125
|
+
| `VigicruesRateLimitError` | The service refused the request: too many requests (HTTP 429). Avoid bursts of requests |
|
|
126
|
+
| `VigicruesBadValueError` | The service rejected a code: unknown or invalid (it does not tell them apart) |
|
|
127
|
+
| `VigicruesUnknownValueError` | The service sent nothing for a code that it did not reject |
|
|
128
|
+
| `VigicruesResponseError` | The service sent an unexpected response: HTTP error, unexpected content or page structure |
|
|
129
|
+
| `VigicruesNotFoundError` | The service does not have the requested resource (HTTP 404); a `VigicruesResponseError` |
|
|
130
|
+
| `VigicruesApiError` | The service reported another error in its response; base class of `VigicruesBadValueError` |
|
|
131
|
+
|
|
132
|
+
## Development
|
|
133
|
+
|
|
134
|
+
Prerequisites: [uv](https://docs.astral.sh/uv/), which manages the Python interpreters, the virtual
|
|
135
|
+
environment (`.venv/`) and the dependencies; [Git](https://git-scm.com/).
|
|
136
|
+
|
|
137
|
+
### Build
|
|
138
|
+
|
|
139
|
+
```powershell
|
|
140
|
+
build.cmd [analyze|build|clean|compile|package|rebuild|release|test|test-live] [/log] [/NoPause] [/?]
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
./build.sh [analyze|build|clean|compile|package|rebuild|release|test|test-live] [--log] [--help]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
| Target | Content |
|
|
148
|
+
|---|---|
|
|
149
|
+
| `clean` | Removes the virtual environment (`.venv/`, recreated right away) and the build outputs (`tmp/`) |
|
|
150
|
+
| `compile` | Formatting, lint and type checks |
|
|
151
|
+
| `test` | `compile`, then the tests with coverage (JUnit, Cobertura and HTML reports in `tmp/`) |
|
|
152
|
+
| `test-live` | The tests that call the real Vigicrues service (marked `live`, excluded from `test`); also run weekly and on demand by the `test-live` GitHub workflow |
|
|
153
|
+
| `analyze` | Lines of code (`tmp/cloc-results.xml`) |
|
|
154
|
+
| `package` | Wheel and source distribution in `tmp/out/bin/` |
|
|
155
|
+
| `build` (default) | `compile`, `test` and `analyze` |
|
|
156
|
+
| `rebuild` | `clean`, then `build` |
|
|
157
|
+
| `release` | `rebuild`, then `package` |
|
|
158
|
+
|
|
159
|
+
The build first updates `.venv` to the latest allowed dependencies (`uv sync --upgrade`), then runs
|
|
160
|
+
the target with [Invoke](https://www.pyinvoke.org/) (`tasks.py`). The output is also written to
|
|
161
|
+
`build.log`. Set `UV_PYTHON` (e.g. `3.11`) to build with another Python version: this recreates
|
|
162
|
+
`.venv` with it.
|
|
163
|
+
|
|
164
|
+
### Individual commands
|
|
165
|
+
|
|
166
|
+
```powershell
|
|
167
|
+
# Create .venv with the Python version from .python-version and install the latest allowed dependencies
|
|
168
|
+
uv sync --upgrade
|
|
169
|
+
|
|
170
|
+
# Run a command in that environment
|
|
171
|
+
uv run python -c "import vigicrues_client"
|
|
172
|
+
|
|
173
|
+
# Static checks: lint, formatting, types (configured in pyproject.toml)
|
|
174
|
+
uv run ruff check
|
|
175
|
+
uv run ruff format --check
|
|
176
|
+
uv run mypy
|
|
177
|
+
|
|
178
|
+
# Tests (tests marked `live` call the real Vigicrues service and only run with `-m live`)
|
|
179
|
+
uv run pytest
|
|
180
|
+
uv run pytest -m live
|
|
181
|
+
|
|
182
|
+
# Tests on another Python version, in a temporary environment (.venv is left untouched)
|
|
183
|
+
uv run --isolated --python 3.11 pytest
|
|
184
|
+
```
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# vigicrues-client
|
|
2
|
+
[](https://pypi.org/project/vigicrues-client/)
|
|
3
|
+
[](https://pypi.org/project/vigicrues-client/)
|
|
4
|
+
[](https://github.com/mcartoixa/vigicrues-client/blob/main/LICENSE)
|
|
5
|
+
[](https://github.com/mcartoixa/vigicrues-client/actions/workflows/build.yml)
|
|
6
|
+
[](https://app.codecov.io/gh/mcartoixa/vigicrues-client)
|
|
7
|
+
|
|
8
|
+
Asynchronous Python client for [Vigicrues](https://www.vigicrues.gouv.fr/), the French flood
|
|
9
|
+
vigilance service: water heights and flow rates observed at the hydrometric stations, flood vigilance
|
|
10
|
+
levels and bulletins of the river sections.
|
|
11
|
+
|
|
12
|
+
This project is not affiliated with Vigicrues. It reads the services and pages of the Vigicrues web
|
|
13
|
+
site, which are not documented as a public API: they may change without notice.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Requires Python 3.11 or later.
|
|
18
|
+
|
|
19
|
+
```powershell
|
|
20
|
+
pip install vigicrues-client
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
import asyncio
|
|
27
|
+
|
|
28
|
+
from vigicrues_client import Quantity, VigicruesClient, VigilanceLevel
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
async def main() -> None:
|
|
32
|
+
async with VigicruesClient() as client:
|
|
33
|
+
# Water heights observed at a station, in metres
|
|
34
|
+
heights = await client.get_observations("O262002001")
|
|
35
|
+
if heights.latest is not None:
|
|
36
|
+
print(f"{heights.station_name}: {heights.latest.value} m")
|
|
37
|
+
|
|
38
|
+
# Flow rates, in cubic metres per second
|
|
39
|
+
flows = await client.get_observations("E540031001", Quantity.FLOW)
|
|
40
|
+
if flows.latest is not None:
|
|
41
|
+
print(f"{flows.station_name}: {flows.latest.value} m³/s")
|
|
42
|
+
|
|
43
|
+
# Flood vigilance of a river section: level and forecaster's comments
|
|
44
|
+
vigilance = await client.get_river_section_vigilance("MP18")
|
|
45
|
+
print(f"{vigilance.section.name}: {vigilance.level.name}")
|
|
46
|
+
for comment in vigilance.comments:
|
|
47
|
+
print(comment)
|
|
48
|
+
print(vigilance.bulletin.general_comment)
|
|
49
|
+
|
|
50
|
+
# Levels of all the river sections of metropolitan France at once
|
|
51
|
+
levels = await client.get_vigilance_levels()
|
|
52
|
+
in_vigilance = [
|
|
53
|
+
code
|
|
54
|
+
for code, level in levels.levels.items()
|
|
55
|
+
if level >= VigilanceLevel.YELLOW
|
|
56
|
+
]
|
|
57
|
+
print(f"In vigilance at {levels.time}: {in_vigilance}")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
asyncio.run(main())
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
| Method | Returns |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `get_observations(station, quantity)` | Recent heights or flow rates observed at a station |
|
|
66
|
+
| `get_station(station)` | Details of a station: river, territory, historical floods, stations of the basin |
|
|
67
|
+
| `get_territory(territory)` | A flood vigilance territory and its river sections |
|
|
68
|
+
| `get_river_section(section)` | A river section, its territory and its stations |
|
|
69
|
+
| `get_vigilance_levels()` | Vigilance levels of all the river sections of metropolitan France |
|
|
70
|
+
| `get_vigilance_level(section)` | Vigilance level of a river section |
|
|
71
|
+
| `get_territory_bulletin(territory)` | Vigilance bulletin of a territory: situation, comments, levels of the river sections |
|
|
72
|
+
| `get_river_section_vigilance(section)` | Vigilance level and comments of a river section, with the bulletin of its territory |
|
|
73
|
+
|
|
74
|
+
The bulletins are read from the HTML pages of the Vigicrues web site, and are the most likely to break
|
|
75
|
+
when the site changes.
|
|
76
|
+
|
|
77
|
+
### HTTP session
|
|
78
|
+
|
|
79
|
+
By default, the client creates its own [aiohttp](https://docs.aiohttp.org/) session and closes it
|
|
80
|
+
with the client. An application can pass its own session instead, which the client never closes:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
async with aiohttp.ClientSession() as session:
|
|
84
|
+
client = VigicruesClient(session)
|
|
85
|
+
series = await client.get_observations("O262002001")
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Errors
|
|
89
|
+
|
|
90
|
+
All the errors derive from `VigicruesError`:
|
|
91
|
+
|
|
92
|
+
| Error | Raised when |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `VigicruesConnectionError` | The service could not be reached or did not answer in time (`timeout` argument of the client, in seconds) |
|
|
95
|
+
| `VigicruesRateLimitError` | The service refused the request: too many requests (HTTP 429). Avoid bursts of requests |
|
|
96
|
+
| `VigicruesBadValueError` | The service rejected a code: unknown or invalid (it does not tell them apart) |
|
|
97
|
+
| `VigicruesUnknownValueError` | The service sent nothing for a code that it did not reject |
|
|
98
|
+
| `VigicruesResponseError` | The service sent an unexpected response: HTTP error, unexpected content or page structure |
|
|
99
|
+
| `VigicruesNotFoundError` | The service does not have the requested resource (HTTP 404); a `VigicruesResponseError` |
|
|
100
|
+
| `VigicruesApiError` | The service reported another error in its response; base class of `VigicruesBadValueError` |
|
|
101
|
+
|
|
102
|
+
## Development
|
|
103
|
+
|
|
104
|
+
Prerequisites: [uv](https://docs.astral.sh/uv/), which manages the Python interpreters, the virtual
|
|
105
|
+
environment (`.venv/`) and the dependencies; [Git](https://git-scm.com/).
|
|
106
|
+
|
|
107
|
+
### Build
|
|
108
|
+
|
|
109
|
+
```powershell
|
|
110
|
+
build.cmd [analyze|build|clean|compile|package|rebuild|release|test|test-live] [/log] [/NoPause] [/?]
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
./build.sh [analyze|build|clean|compile|package|rebuild|release|test|test-live] [--log] [--help]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
| Target | Content |
|
|
118
|
+
|---|---|
|
|
119
|
+
| `clean` | Removes the virtual environment (`.venv/`, recreated right away) and the build outputs (`tmp/`) |
|
|
120
|
+
| `compile` | Formatting, lint and type checks |
|
|
121
|
+
| `test` | `compile`, then the tests with coverage (JUnit, Cobertura and HTML reports in `tmp/`) |
|
|
122
|
+
| `test-live` | The tests that call the real Vigicrues service (marked `live`, excluded from `test`); also run weekly and on demand by the `test-live` GitHub workflow |
|
|
123
|
+
| `analyze` | Lines of code (`tmp/cloc-results.xml`) |
|
|
124
|
+
| `package` | Wheel and source distribution in `tmp/out/bin/` |
|
|
125
|
+
| `build` (default) | `compile`, `test` and `analyze` |
|
|
126
|
+
| `rebuild` | `clean`, then `build` |
|
|
127
|
+
| `release` | `rebuild`, then `package` |
|
|
128
|
+
|
|
129
|
+
The build first updates `.venv` to the latest allowed dependencies (`uv sync --upgrade`), then runs
|
|
130
|
+
the target with [Invoke](https://www.pyinvoke.org/) (`tasks.py`). The output is also written to
|
|
131
|
+
`build.log`. Set `UV_PYTHON` (e.g. `3.11`) to build with another Python version: this recreates
|
|
132
|
+
`.venv` with it.
|
|
133
|
+
|
|
134
|
+
### Individual commands
|
|
135
|
+
|
|
136
|
+
```powershell
|
|
137
|
+
# Create .venv with the Python version from .python-version and install the latest allowed dependencies
|
|
138
|
+
uv sync --upgrade
|
|
139
|
+
|
|
140
|
+
# Run a command in that environment
|
|
141
|
+
uv run python -c "import vigicrues_client"
|
|
142
|
+
|
|
143
|
+
# Static checks: lint, formatting, types (configured in pyproject.toml)
|
|
144
|
+
uv run ruff check
|
|
145
|
+
uv run ruff format --check
|
|
146
|
+
uv run mypy
|
|
147
|
+
|
|
148
|
+
# Tests (tests marked `live` call the real Vigicrues service and only run with `-m live`)
|
|
149
|
+
uv run pytest
|
|
150
|
+
uv run pytest -m live
|
|
151
|
+
|
|
152
|
+
# Tests on another Python version, in a temporary environment (.venv is left untouched)
|
|
153
|
+
uv run --isolated --python 3.11 pytest
|
|
154
|
+
```
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "vigicrues-client"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "Asynchronous Python client for Vigicrues, the French flood vigilance service"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
keywords = [
|
|
9
|
+
"vigicrues",
|
|
10
|
+
"flood",
|
|
11
|
+
"hydrology",
|
|
12
|
+
"france",
|
|
13
|
+
"asyncio",
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Framework :: AsyncIO",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Programming Language :: Python :: 3.14",
|
|
26
|
+
"Programming Language :: Python :: 3.15",
|
|
27
|
+
"Topic :: Scientific/Engineering :: Hydrology",
|
|
28
|
+
"Typing :: Typed",
|
|
29
|
+
]
|
|
30
|
+
requires-python = ">=3.11"
|
|
31
|
+
dependencies = [
|
|
32
|
+
"aiohttp>=3.9",
|
|
33
|
+
"beautifulsoup4>=4.13.1",
|
|
34
|
+
"tzdata>=2025.2",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[[project.authors]]
|
|
38
|
+
name = "Mathieu Cartoixa"
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Repository = "https://github.com/mcartoixa/vigicrues-client"
|
|
42
|
+
Issues = "https://github.com/mcartoixa/vigicrues-client/issues"
|
|
43
|
+
Changelog = "https://github.com/mcartoixa/vigicrues-client/releases"
|
|
44
|
+
|
|
45
|
+
[dependency-groups]
|
|
46
|
+
dev = [
|
|
47
|
+
"invoke>=3.0.3",
|
|
48
|
+
"mypy>=2.4.1",
|
|
49
|
+
"pygount>=3.2.0",
|
|
50
|
+
"pytest>=9.2.0",
|
|
51
|
+
"pytest-asyncio>=1.5.0",
|
|
52
|
+
"pytest-cov>=7.1.0",
|
|
53
|
+
"ruff>=0.17.5",
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
[build-system]
|
|
57
|
+
requires = ["uv_build>=0.13.9,<0.14.0"]
|
|
58
|
+
build-backend = "uv_build"
|
|
59
|
+
|
|
60
|
+
[tool.uv]
|
|
61
|
+
exclude-newer = "7 days"
|
|
62
|
+
|
|
63
|
+
[tool.ruff]
|
|
64
|
+
cache-dir = ".tmp/ruff-cache"
|
|
65
|
+
|
|
66
|
+
[tool.ruff.lint]
|
|
67
|
+
select = [
|
|
68
|
+
"ASYNC",
|
|
69
|
+
"B",
|
|
70
|
+
"C4",
|
|
71
|
+
"D",
|
|
72
|
+
"E",
|
|
73
|
+
"F",
|
|
74
|
+
"I",
|
|
75
|
+
"N",
|
|
76
|
+
"PT",
|
|
77
|
+
"RUF",
|
|
78
|
+
"SIM",
|
|
79
|
+
"UP",
|
|
80
|
+
"W",
|
|
81
|
+
]
|
|
82
|
+
ignore = [
|
|
83
|
+
"D105",
|
|
84
|
+
"D107",
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
[tool.ruff.lint.per-file-ignores]
|
|
88
|
+
"tests/**" = ["D"]
|
|
89
|
+
|
|
90
|
+
[tool.ruff.lint.pydocstyle]
|
|
91
|
+
convention = "google"
|
|
92
|
+
|
|
93
|
+
[tool.mypy]
|
|
94
|
+
cache_dir = "$MYPY_CONFIG_FILE_DIR/.tmp/mypy-cache"
|
|
95
|
+
files = [
|
|
96
|
+
"$MYPY_CONFIG_FILE_DIR/src",
|
|
97
|
+
"$MYPY_CONFIG_FILE_DIR/tests",
|
|
98
|
+
"$MYPY_CONFIG_FILE_DIR/tasks.py",
|
|
99
|
+
]
|
|
100
|
+
python_version = "3.11"
|
|
101
|
+
strict = true
|
|
102
|
+
warn_unreachable = true
|
|
103
|
+
enable_error_code = [
|
|
104
|
+
"ignore-without-code",
|
|
105
|
+
"redundant-expr",
|
|
106
|
+
"truthy-bool",
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[tool.pytest]
|
|
110
|
+
addopts = [
|
|
111
|
+
"--import-mode=importlib",
|
|
112
|
+
"-m",
|
|
113
|
+
"not live",
|
|
114
|
+
]
|
|
115
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
116
|
+
asyncio_mode = "auto"
|
|
117
|
+
cache_dir = ".tmp/pytest-cache"
|
|
118
|
+
filterwarnings = ["error"]
|
|
119
|
+
markers = ["live: calls the real Vigicrues service (deselected by default, run with `-m live`)"]
|
|
120
|
+
strict = true
|
|
121
|
+
testpaths = ["tests"]
|
|
122
|
+
|
|
123
|
+
[tool.coverage.run]
|
|
124
|
+
branch = true
|
|
125
|
+
data_file = "tmp/tst/.coverage"
|
|
126
|
+
source_pkgs = ["vigicrues_client"]
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "vigicrues-client"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "Asynchronous Python client for Vigicrues, the French flood vigilance service"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Mathieu Cartoixa" },
|
|
10
|
+
]
|
|
11
|
+
keywords = ["vigicrues", "flood", "hydrology", "france", "asyncio"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Framework :: AsyncIO",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Programming Language :: Python :: 3.15",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Hydrology",
|
|
25
|
+
"Typing :: Typed",
|
|
26
|
+
]
|
|
27
|
+
requires-python = ">=3.11"
|
|
28
|
+
dependencies = [
|
|
29
|
+
"aiohttp>=3.9",
|
|
30
|
+
"beautifulsoup4>=4.13.1",
|
|
31
|
+
"tzdata>=2025.2",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Repository = "https://github.com/mcartoixa/vigicrues-client"
|
|
36
|
+
Issues = "https://github.com/mcartoixa/vigicrues-client/issues"
|
|
37
|
+
Changelog = "https://github.com/mcartoixa/vigicrues-client/releases"
|
|
38
|
+
|
|
39
|
+
[dependency-groups]
|
|
40
|
+
dev = [
|
|
41
|
+
"invoke>=3.0.3",
|
|
42
|
+
"mypy>=2.4.1",
|
|
43
|
+
"pygount>=3.2.0",
|
|
44
|
+
"pytest>=9.2.0",
|
|
45
|
+
"pytest-asyncio>=1.5.0",
|
|
46
|
+
"pytest-cov>=7.1.0",
|
|
47
|
+
"ruff>=0.17.5",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[build-system]
|
|
51
|
+
requires = ["uv_build>=0.13.9,<0.14.0"]
|
|
52
|
+
build-backend = "uv_build"
|
|
53
|
+
|
|
54
|
+
[tool.uv]
|
|
55
|
+
# Supply-chain cooldown for development and CI: ignore releases uploaded in the last 7 days, the time
|
|
56
|
+
# it usually takes for a malicious release to be detected and removed. Does not affect library users.
|
|
57
|
+
exclude-newer = "7 days"
|
|
58
|
+
|
|
59
|
+
[tool.ruff]
|
|
60
|
+
cache-dir = ".tmp/ruff-cache"
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
select = [
|
|
64
|
+
"ASYNC", # flake8-async: blocking calls and other pitfalls in async code
|
|
65
|
+
"B", # flake8-bugbear: likely bugs and design problems
|
|
66
|
+
"C4", # flake8-comprehensions: unnecessary or convoluted comprehensions
|
|
67
|
+
"D", # pydocstyle: docstrings on the public API
|
|
68
|
+
"E", # pycodestyle errors
|
|
69
|
+
"F", # Pyflakes: unused imports, undefined names...
|
|
70
|
+
"I", # isort: import sorting
|
|
71
|
+
"N", # pep8-naming
|
|
72
|
+
"PT", # flake8-pytest-style
|
|
73
|
+
"RUF", # Ruff-specific rules
|
|
74
|
+
"SIM", # flake8-simplify
|
|
75
|
+
"UP", # pyupgrade: modern syntax for the minimum Python version
|
|
76
|
+
"W", # pycodestyle warnings
|
|
77
|
+
]
|
|
78
|
+
ignore = [
|
|
79
|
+
"D105", # Magic methods (__aenter__, __repr__...) have well-known meanings
|
|
80
|
+
"D107", # __init__ arguments are documented in the class docstring (Google style)
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[tool.ruff.lint.per-file-ignores]
|
|
84
|
+
"tests/**" = ["D"]
|
|
85
|
+
|
|
86
|
+
[tool.ruff.lint.pydocstyle]
|
|
87
|
+
convention = "google"
|
|
88
|
+
|
|
89
|
+
[tool.mypy]
|
|
90
|
+
# Mypy resolves relative paths from the current directory: anchor them to this file's directory.
|
|
91
|
+
cache_dir = "$MYPY_CONFIG_FILE_DIR/.tmp/mypy-cache"
|
|
92
|
+
files = ["$MYPY_CONFIG_FILE_DIR/src", "$MYPY_CONFIG_FILE_DIR/tests", "$MYPY_CONFIG_FILE_DIR/tasks.py"]
|
|
93
|
+
# Check against the oldest supported version, so that newer standard library APIs are reported.
|
|
94
|
+
python_version = "3.11"
|
|
95
|
+
strict = true
|
|
96
|
+
warn_unreachable = true
|
|
97
|
+
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
|
|
98
|
+
|
|
99
|
+
[tool.pytest]
|
|
100
|
+
addopts = ["--import-mode=importlib", "-m", "not live"]
|
|
101
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
102
|
+
asyncio_mode = "auto"
|
|
103
|
+
cache_dir = ".tmp/pytest-cache"
|
|
104
|
+
filterwarnings = ["error"]
|
|
105
|
+
markers = [
|
|
106
|
+
"live: calls the real Vigicrues service (deselected by default, run with `-m live`)",
|
|
107
|
+
]
|
|
108
|
+
strict = true
|
|
109
|
+
testpaths = ["tests"]
|
|
110
|
+
|
|
111
|
+
[tool.coverage.run]
|
|
112
|
+
branch = true
|
|
113
|
+
# Relative to the current directory (the project root for the build, uv and IDEs). The build
|
|
114
|
+
# sets the same location with COVERAGE_FILE, which takes precedence.
|
|
115
|
+
data_file = "tmp/tst/.coverage"
|
|
116
|
+
source_pkgs = ["vigicrues_client"]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Asynchronous Python client for Vigicrues, the French flood vigilance service."""
|
|
2
|
+
|
|
3
|
+
from ._client import VigicruesClient
|
|
4
|
+
from ._errors import (
|
|
5
|
+
VigicruesApiError,
|
|
6
|
+
VigicruesBadValueError,
|
|
7
|
+
VigicruesConnectionError,
|
|
8
|
+
VigicruesError,
|
|
9
|
+
VigicruesNotFoundError,
|
|
10
|
+
VigicruesRateLimitError,
|
|
11
|
+
VigicruesResponseError,
|
|
12
|
+
VigicruesUnknownValueError,
|
|
13
|
+
)
|
|
14
|
+
from ._models import (
|
|
15
|
+
BasinStation,
|
|
16
|
+
BulletinRiverSection,
|
|
17
|
+
HistoricalFlood,
|
|
18
|
+
Observation,
|
|
19
|
+
ObservationSeries,
|
|
20
|
+
Quantity,
|
|
21
|
+
RiverSection,
|
|
22
|
+
RiverSectionStation,
|
|
23
|
+
RiverSectionVigilance,
|
|
24
|
+
Station,
|
|
25
|
+
Territory,
|
|
26
|
+
TerritoryBulletin,
|
|
27
|
+
TerritoryRiverSection,
|
|
28
|
+
VigilanceLevel,
|
|
29
|
+
VigilanceLevels,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
__all__ = [
|
|
33
|
+
"BasinStation",
|
|
34
|
+
"BulletinRiverSection",
|
|
35
|
+
"HistoricalFlood",
|
|
36
|
+
"Observation",
|
|
37
|
+
"ObservationSeries",
|
|
38
|
+
"Quantity",
|
|
39
|
+
"RiverSection",
|
|
40
|
+
"RiverSectionStation",
|
|
41
|
+
"RiverSectionVigilance",
|
|
42
|
+
"Station",
|
|
43
|
+
"Territory",
|
|
44
|
+
"TerritoryBulletin",
|
|
45
|
+
"TerritoryRiverSection",
|
|
46
|
+
"VigicruesApiError",
|
|
47
|
+
"VigicruesBadValueError",
|
|
48
|
+
"VigicruesClient",
|
|
49
|
+
"VigicruesConnectionError",
|
|
50
|
+
"VigicruesError",
|
|
51
|
+
"VigicruesNotFoundError",
|
|
52
|
+
"VigicruesRateLimitError",
|
|
53
|
+
"VigicruesResponseError",
|
|
54
|
+
"VigicruesUnknownValueError",
|
|
55
|
+
"VigilanceLevel",
|
|
56
|
+
"VigilanceLevels",
|
|
57
|
+
]
|