meteostat-cli 0.4.0__tar.gz → 0.5.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.
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/PKG-INFO +2 -1
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/__init__.py +1 -1
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/contrib/build.py +20 -5
- meteostat_cli-0.5.0/meteo/contrib/database.py +207 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/pyproject.toml +2 -1
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/tests/test_contrib.py +61 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/uv.lock +59 -0
- meteostat_cli-0.4.0/meteo/contrib/database.py +0 -103
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/.claude/skills/meteo/SKILL.md +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/.github/workflows/lint.yml +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/.github/workflows/publish.yml +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/.github/workflows/test.yml +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/.gitignore +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/LICENSE +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/README.md +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/demo.gif +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/demo.yml +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/cli.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/__init__.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/config.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/contrib/__init__.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/contrib/add.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/contrib/delete.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/contrib/duplicates.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/contrib/edit.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/contrib/validate.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/daily.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/hourly.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/inventory.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/monthly.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/nearby.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/normals.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/commands/station.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/config.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/contrib/__init__.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/contrib/duplicates.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/contrib/repo.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/contrib/validation.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/plotting.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/meteo/utils.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/tests/__init__.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/tests/conftest.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/tests/test_cli.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/tests/test_commands.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/tests/test_config.py +0 -0
- {meteostat_cli-0.4.0 → meteostat_cli-0.5.0}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: meteostat-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Access weather and climate data through the terminal.
|
|
5
5
|
Project-URL: Homepage, https://github.com/meteostat/cli
|
|
6
6
|
Project-URL: Repository, https://github.com/meteostat/cli
|
|
@@ -23,6 +23,7 @@ Requires-Dist: pyyaml>=6.0
|
|
|
23
23
|
Requires-Dist: typer>=0.15.0
|
|
24
24
|
Provides-Extra: contrib
|
|
25
25
|
Requires-Dist: jsonschema>=4.20.0; extra == 'contrib'
|
|
26
|
+
Requires-Dist: pyarrow>=18.0.0; extra == 'contrib'
|
|
26
27
|
Requires-Dist: pycountry>=24.6.1; extra == 'contrib'
|
|
27
28
|
Provides-Extra: plot
|
|
28
29
|
Requires-Dist: matplotlib>=3.9.0; extra == 'plot'
|
|
@@ -1,30 +1,45 @@
|
|
|
1
1
|
"""Build station database command for the Meteostat CLI."""
|
|
2
2
|
|
|
3
|
+
from enum import StrEnum
|
|
3
4
|
from pathlib import Path
|
|
4
5
|
|
|
5
6
|
import typer
|
|
6
7
|
|
|
7
8
|
from meteo.commands.contrib import REPO_HELP, echo_report, plural
|
|
8
|
-
from meteo.contrib.database import build_database
|
|
9
|
+
from meteo.contrib.database import build_database, build_parquet
|
|
9
10
|
from meteo.contrib.repo import load_stations, resolve_repo, station_files
|
|
10
11
|
from meteo.contrib.validation import Validator
|
|
11
12
|
|
|
12
13
|
|
|
14
|
+
class Format(StrEnum):
|
|
15
|
+
sqlite = "sqlite"
|
|
16
|
+
parquet = "parquet"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
BUILDERS = {Format.sqlite: build_database, Format.parquet: build_parquet}
|
|
20
|
+
DEFAULT_FILES = {Format.sqlite: "stations.db", Format.parquet: "stations.parquet"}
|
|
21
|
+
|
|
22
|
+
|
|
13
23
|
def build_cmd(
|
|
14
24
|
output: str | None = typer.Option(
|
|
15
25
|
None,
|
|
16
26
|
"--output",
|
|
17
27
|
"-o",
|
|
18
|
-
help="Output file path (default: stations.db in the repository root).",
|
|
28
|
+
help="Output file path (default: stations.db or stations.parquet in the repository root).",
|
|
29
|
+
),
|
|
30
|
+
fmt: Format = typer.Option(
|
|
31
|
+
Format.sqlite, "--format", "-f", help="Output format.", case_sensitive=False
|
|
19
32
|
),
|
|
20
33
|
skip_validation: bool = typer.Option(
|
|
21
34
|
False, "--skip-validation", help="Don't validate stations before building."
|
|
22
35
|
),
|
|
23
36
|
repo: str | None = typer.Option(None, "--repo", help=REPO_HELP),
|
|
24
37
|
) -> None:
|
|
25
|
-
"""Build a SQLite database from the station files."""
|
|
38
|
+
"""Build a SQLite database or Parquet file from the station files."""
|
|
26
39
|
repo_path = resolve_repo(repo)
|
|
27
|
-
output_path =
|
|
40
|
+
output_path = (
|
|
41
|
+
Path(output).expanduser() if output else repo_path / DEFAULT_FILES[fmt]
|
|
42
|
+
)
|
|
28
43
|
stations = load_stations(repo_path)
|
|
29
44
|
|
|
30
45
|
skipped = 0
|
|
@@ -37,7 +52,7 @@ def build_cmd(
|
|
|
37
52
|
stations.pop(path.stem, None)
|
|
38
53
|
skipped += 1
|
|
39
54
|
|
|
40
|
-
count, failed =
|
|
55
|
+
count, failed = BUILDERS[fmt](stations, output_path)
|
|
41
56
|
for station_id, reason in failed:
|
|
42
57
|
typer.echo(f"{typer.style('✗', fg='red')} {station_id} {reason}")
|
|
43
58
|
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"""Build a SQLite database or Parquet file from station files."""
|
|
2
|
+
|
|
3
|
+
import sqlite3
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
|
|
9
|
+
TABLES_SQL = """
|
|
10
|
+
CREATE TABLE `stations` (
|
|
11
|
+
`id` char(5) NOT NULL PRIMARY KEY,
|
|
12
|
+
`country` varchar(2) DEFAULT NULL,
|
|
13
|
+
`region` varchar(5) DEFAULT NULL,
|
|
14
|
+
`latitude` float(8,4) DEFAULT NULL,
|
|
15
|
+
`longitude` float(8,4) DEFAULT NULL,
|
|
16
|
+
`elevation` int(4) DEFAULT NULL,
|
|
17
|
+
`timezone` varchar(30) DEFAULT NULL
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
CREATE TABLE `names` (
|
|
21
|
+
`station` char(5) NOT NULL,
|
|
22
|
+
`language` char(2) NOT NULL,
|
|
23
|
+
`name` varchar(255) NOT NULL,
|
|
24
|
+
PRIMARY KEY (`station`, `language`)
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
CREATE TABLE `identifiers` (
|
|
28
|
+
`station` char(5) NOT NULL,
|
|
29
|
+
`key` varchar(255) NOT NULL,
|
|
30
|
+
`value` varchar(255) NOT NULL,
|
|
31
|
+
PRIMARY KEY (`station`, `key`)
|
|
32
|
+
);
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def build_database(
|
|
37
|
+
stations: dict[str, dict[str, Any]], output: Path
|
|
38
|
+
) -> tuple[int, list[tuple[str, str]]]:
|
|
39
|
+
"""Write stations to a new SQLite database at ``output``.
|
|
40
|
+
|
|
41
|
+
Inactive stations are left out, like in the official database. The file is
|
|
42
|
+
only replaced once the database was built successfully.
|
|
43
|
+
|
|
44
|
+
Returns the number of stations written and a list of (id, reason) for
|
|
45
|
+
stations which could not be written.
|
|
46
|
+
"""
|
|
47
|
+
output.parent.mkdir(parents=True, exist_ok=True)
|
|
48
|
+
tmp = output.with_name(f"{output.name}.tmp")
|
|
49
|
+
tmp.unlink(missing_ok=True)
|
|
50
|
+
|
|
51
|
+
count = 0
|
|
52
|
+
failed: list[tuple[str, str]] = []
|
|
53
|
+
conn = sqlite3.connect(tmp, isolation_level=None)
|
|
54
|
+
try:
|
|
55
|
+
conn.executescript(TABLES_SQL)
|
|
56
|
+
conn.execute("BEGIN")
|
|
57
|
+
for station_id, data in stations.items():
|
|
58
|
+
if data.get("active", True) is False:
|
|
59
|
+
continue
|
|
60
|
+
# Roll back partial inserts of stations which can't be written
|
|
61
|
+
conn.execute("SAVEPOINT station")
|
|
62
|
+
try:
|
|
63
|
+
_insert(conn, data)
|
|
64
|
+
count += 1
|
|
65
|
+
except (KeyError, TypeError, AttributeError, sqlite3.Error) as exc:
|
|
66
|
+
conn.execute("ROLLBACK TO station")
|
|
67
|
+
failed.append((station_id, _describe(exc)))
|
|
68
|
+
conn.execute("RELEASE station")
|
|
69
|
+
conn.execute("COMMIT")
|
|
70
|
+
finally:
|
|
71
|
+
conn.close()
|
|
72
|
+
|
|
73
|
+
tmp.replace(output)
|
|
74
|
+
return count, failed
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _insert(conn: sqlite3.Connection, data: dict[str, Any]) -> None:
|
|
78
|
+
station_id = data["id"]
|
|
79
|
+
location = data["location"]
|
|
80
|
+
conn.execute(
|
|
81
|
+
"INSERT INTO `stations` VALUES (?, ?, ?, ?, ?, ?, ?)",
|
|
82
|
+
(
|
|
83
|
+
station_id,
|
|
84
|
+
data["country"],
|
|
85
|
+
data.get("region"),
|
|
86
|
+
location["latitude"],
|
|
87
|
+
location["longitude"],
|
|
88
|
+
location["elevation"],
|
|
89
|
+
data["timezone"],
|
|
90
|
+
),
|
|
91
|
+
)
|
|
92
|
+
conn.executemany(
|
|
93
|
+
"INSERT INTO `names` VALUES (?, ?, ?)",
|
|
94
|
+
[(station_id, lang, name) for lang, name in data["name"].items()],
|
|
95
|
+
)
|
|
96
|
+
conn.executemany(
|
|
97
|
+
"INSERT INTO `identifiers` VALUES (?, ?, ?)",
|
|
98
|
+
[(station_id, key, value) for key, value in data["identifiers"].items()],
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def build_parquet(
|
|
103
|
+
stations: dict[str, dict[str, Any]], output: Path
|
|
104
|
+
) -> tuple[int, list[tuple[str, str]]]:
|
|
105
|
+
"""Write stations to a Parquet file at ``output``.
|
|
106
|
+
|
|
107
|
+
One row per station, sorted by ID. ``name`` holds the English name,
|
|
108
|
+
``names`` the names in other languages and ``identifiers`` all identifiers,
|
|
109
|
+
so new languages or identifier keys don't change the schema. Inactive
|
|
110
|
+
stations are left out, like in the SQLite database.
|
|
111
|
+
|
|
112
|
+
Returns the number of stations written and a list of (id, reason) for
|
|
113
|
+
stations which could not be written.
|
|
114
|
+
"""
|
|
115
|
+
try:
|
|
116
|
+
import pyarrow as pa
|
|
117
|
+
import pyarrow.parquet as pq
|
|
118
|
+
except ImportError:
|
|
119
|
+
typer.echo(
|
|
120
|
+
"Error: Additional dependencies are required for Parquet output. "
|
|
121
|
+
'Install with: uv tool install "meteostat-cli[contrib]"',
|
|
122
|
+
err=True,
|
|
123
|
+
)
|
|
124
|
+
raise typer.Exit(1) from None
|
|
125
|
+
|
|
126
|
+
text_map = pa.map_(pa.string(), pa.string())
|
|
127
|
+
schema = pa.schema(
|
|
128
|
+
[
|
|
129
|
+
pa.field("id", pa.string(), nullable=False),
|
|
130
|
+
pa.field("name", pa.string(), nullable=False),
|
|
131
|
+
pa.field("names", text_map),
|
|
132
|
+
pa.field("country", pa.string()),
|
|
133
|
+
pa.field("region", pa.string()),
|
|
134
|
+
pa.field("latitude", pa.float64()),
|
|
135
|
+
pa.field("longitude", pa.float64()),
|
|
136
|
+
pa.field("elevation", pa.int16()),
|
|
137
|
+
pa.field("timezone", pa.string()),
|
|
138
|
+
pa.field("identifiers", text_map),
|
|
139
|
+
]
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
rows: list[dict[str, Any]] = []
|
|
143
|
+
failed: list[tuple[str, str]] = []
|
|
144
|
+
for station_id in sorted(stations):
|
|
145
|
+
data = stations[station_id]
|
|
146
|
+
if data.get("active", True) is False:
|
|
147
|
+
continue
|
|
148
|
+
try:
|
|
149
|
+
rows.append(_parquet_row(data))
|
|
150
|
+
except (KeyError, TypeError, AttributeError, ValueError) as exc:
|
|
151
|
+
failed.append((station_id, _describe(exc)))
|
|
152
|
+
|
|
153
|
+
output.parent.mkdir(parents=True, exist_ok=True)
|
|
154
|
+
tmp = output.with_name(f"{output.name}.tmp")
|
|
155
|
+
table = pa.Table.from_pylist(rows, schema=schema)
|
|
156
|
+
# One row group; dictionary encoding only pays off for the repetitive
|
|
157
|
+
# columns. The file is written once and downloaded often, so compress hard.
|
|
158
|
+
pq.write_table(
|
|
159
|
+
table,
|
|
160
|
+
tmp,
|
|
161
|
+
compression="zstd",
|
|
162
|
+
compression_level=19,
|
|
163
|
+
use_dictionary=["country", "region", "timezone"],
|
|
164
|
+
row_group_size=len(rows) or None,
|
|
165
|
+
)
|
|
166
|
+
tmp.replace(output)
|
|
167
|
+
return len(rows), failed
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _parquet_row(data: dict[str, Any]) -> dict[str, Any]:
|
|
171
|
+
names = dict(data["name"])
|
|
172
|
+
name = names.pop("en")
|
|
173
|
+
location = data["location"]
|
|
174
|
+
elevation = location["elevation"]
|
|
175
|
+
if elevation is not None and not -32768 <= elevation <= 32767:
|
|
176
|
+
raise ValueError(f"Elevation {elevation} out of range")
|
|
177
|
+
row = {
|
|
178
|
+
"id": str(data["id"]),
|
|
179
|
+
"name": str(name),
|
|
180
|
+
"names": _pairs(names),
|
|
181
|
+
"country": data["country"],
|
|
182
|
+
"region": data.get("region"),
|
|
183
|
+
"latitude": _float(location["latitude"]),
|
|
184
|
+
"longitude": _float(location["longitude"]),
|
|
185
|
+
"elevation": None if elevation is None else int(elevation),
|
|
186
|
+
"timezone": data["timezone"],
|
|
187
|
+
"identifiers": _pairs(data["identifiers"]),
|
|
188
|
+
}
|
|
189
|
+
for key in ("country", "region", "timezone"):
|
|
190
|
+
if row[key] is not None and not isinstance(row[key], str):
|
|
191
|
+
raise TypeError(f"{key} must be a string")
|
|
192
|
+
return row
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _pairs(mapping: dict[str, Any]) -> list[tuple[str, str]] | None:
|
|
196
|
+
"""Sorted (key, value) pairs of a map column; None if there are none."""
|
|
197
|
+
return [(str(k), str(v)) for k, v in sorted(mapping.items())] or None
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def _float(value: Any) -> float | None:
|
|
201
|
+
return None if value is None else float(value)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def _describe(exc: Exception) -> str:
|
|
205
|
+
if isinstance(exc, KeyError):
|
|
206
|
+
return f"Missing property {exc}"
|
|
207
|
+
return f"Could not be written: {exc}"
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "meteostat-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.5.0"
|
|
8
8
|
description = "Access weather and climate data through the terminal."
|
|
9
9
|
authors = [{ name = "Meteostat", email = "info@meteostat.net" }]
|
|
10
10
|
readme = "README.md"
|
|
@@ -31,6 +31,7 @@ dependencies = [
|
|
|
31
31
|
plot = ["matplotlib>=3.9.0"]
|
|
32
32
|
contrib = [
|
|
33
33
|
"jsonschema>=4.20.0",
|
|
34
|
+
"pyarrow>=18.0.0",
|
|
34
35
|
"pycountry>=24.6.1",
|
|
35
36
|
]
|
|
36
37
|
providers = [
|
|
@@ -9,6 +9,7 @@ import sys
|
|
|
9
9
|
from pathlib import Path
|
|
10
10
|
from unittest.mock import patch
|
|
11
11
|
|
|
12
|
+
import pyarrow.parquet as pq
|
|
12
13
|
import pytest
|
|
13
14
|
import typer
|
|
14
15
|
|
|
@@ -595,3 +596,63 @@ class TestBuild:
|
|
|
595
596
|
assert "with 3 stations (1 skipped)" in result.output
|
|
596
597
|
assert output.exists()
|
|
597
598
|
assert not (repo / "stations.db").exists()
|
|
599
|
+
|
|
600
|
+
def test_build_parquet(self, run, repo, monkeypatch):
|
|
601
|
+
schema = load_schema()
|
|
602
|
+
schema["properties"]["active"] = {"type": "boolean"}
|
|
603
|
+
monkeypatch.setattr(
|
|
604
|
+
"meteo.contrib.validation.load_schema", lambda: copy.deepcopy(schema)
|
|
605
|
+
)
|
|
606
|
+
write(repo, BERLIN | {"id": "INACT", "identifiers": {}, "active": False})
|
|
607
|
+
write(repo, FRANKFURT | {"id": "BAD00", "identifiers": {}, "timezone": "X"})
|
|
608
|
+
result = run("build", "--format", "parquet")
|
|
609
|
+
assert result.exit_code == 0, result.output
|
|
610
|
+
assert "stations.parquet with 2 stations (1 skipped)" in result.output
|
|
611
|
+
assert not (repo / "stations.db").exists()
|
|
612
|
+
|
|
613
|
+
table = pq.read_table(repo / "stations.parquet")
|
|
614
|
+
assert table.column_names == [
|
|
615
|
+
"id",
|
|
616
|
+
"name",
|
|
617
|
+
"names",
|
|
618
|
+
"country",
|
|
619
|
+
"region",
|
|
620
|
+
"latitude",
|
|
621
|
+
"longitude",
|
|
622
|
+
"elevation",
|
|
623
|
+
"timezone",
|
|
624
|
+
"identifiers",
|
|
625
|
+
]
|
|
626
|
+
rows = table.to_pylist()
|
|
627
|
+
assert [row["id"] for row in rows] == ["10384", "10637"]
|
|
628
|
+
assert rows[1] == {
|
|
629
|
+
"id": "10637",
|
|
630
|
+
"name": "Frankfurt Airport",
|
|
631
|
+
"names": [("de", "Frankfurt Flughafen")],
|
|
632
|
+
"country": "DE",
|
|
633
|
+
"region": "HE",
|
|
634
|
+
"latitude": 50.05,
|
|
635
|
+
"longitude": 8.6,
|
|
636
|
+
"elevation": 111,
|
|
637
|
+
"timezone": "Europe/Berlin",
|
|
638
|
+
"identifiers": [("icao", "EDDF"), ("wmo", "10637")],
|
|
639
|
+
}
|
|
640
|
+
assert rows[0]["names"] is None
|
|
641
|
+
|
|
642
|
+
def test_build_parquet_columns(self, run, repo):
|
|
643
|
+
result = run("build", "-f", "parquet")
|
|
644
|
+
assert result.exit_code == 0, result.output
|
|
645
|
+
table = pq.read_table(
|
|
646
|
+
repo / "stations.parquet", columns=["id", "latitude", "longitude"]
|
|
647
|
+
)
|
|
648
|
+
assert table.to_pylist() == [
|
|
649
|
+
{"id": "10384", "latitude": 52.4667, "longitude": 13.4},
|
|
650
|
+
{"id": "10637", "latitude": 50.05, "longitude": 8.6},
|
|
651
|
+
]
|
|
652
|
+
|
|
653
|
+
def test_build_parquet_without_pyarrow(self, run, repo, monkeypatch):
|
|
654
|
+
monkeypatch.setitem(sys.modules, "pyarrow", None)
|
|
655
|
+
result = run("build", "--format", "parquet")
|
|
656
|
+
assert result.exit_code == 1
|
|
657
|
+
assert "meteostat-cli[contrib]" in result.output
|
|
658
|
+
assert not (repo / "stations.parquet").exists()
|
|
@@ -795,6 +795,7 @@ dependencies = [
|
|
|
795
795
|
[package.optional-dependencies]
|
|
796
796
|
contrib = [
|
|
797
797
|
{ name = "jsonschema" },
|
|
798
|
+
{ name = "pyarrow" },
|
|
798
799
|
{ name = "pycountry" },
|
|
799
800
|
]
|
|
800
801
|
plot = [
|
|
@@ -820,6 +821,7 @@ requires-dist = [
|
|
|
820
821
|
{ name = "matplotlib", marker = "extra == 'plot'", specifier = ">=3.9.0" },
|
|
821
822
|
{ name = "metar", marker = "extra == 'providers'", specifier = ">=1.11.0" },
|
|
822
823
|
{ name = "meteostat", specifier = ">=2.1.5,<3" },
|
|
824
|
+
{ name = "pyarrow", marker = "extra == 'contrib'", specifier = ">=18.0.0" },
|
|
823
825
|
{ name = "pycountry", marker = "extra == 'contrib'", specifier = ">=24.6.1" },
|
|
824
826
|
{ name = "pyyaml", specifier = ">=6.0" },
|
|
825
827
|
{ name = "typer", specifier = ">=0.15.0" },
|
|
@@ -1078,6 +1080,63 @@ wheels = [
|
|
|
1078
1080
|
{ url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" },
|
|
1079
1081
|
]
|
|
1080
1082
|
|
|
1083
|
+
[[package]]
|
|
1084
|
+
name = "pyarrow"
|
|
1085
|
+
version = "26.0.1"
|
|
1086
|
+
source = { registry = "https://pypi.org/simple" }
|
|
1087
|
+
sdist = { url = "https://files.pythonhosted.org/packages/bc/5e/9cb2a56d5e293aab4e2fbecc5b0620d93227d66b8d5a63c554c31e1f80fe/pyarrow-26.0.1.tar.gz", hash = "sha256:93affcbd8a343e98dc19e9ec8fe17271ebf8fe98102d8b7454175074409f8b72", size = 1237985, upload-time = "2026-11-03T10:54:17.563Z" }
|
|
1088
|
+
wheels = [
|
|
1089
|
+
{ url = "https://files.pythonhosted.org/packages/fd/aa/459f3f5adebf6427a8bf1e976168f55793a3732ec1c6c6fe9e05a060b63b/pyarrow-26.0.1-cp311-cp311-macosx_12_0_arm64.whl", hash = "sha256:9a62748f6b1f9f438706f0307acbb26e6a15010ea58f202c9d2725bc6eac0871", size = 37327168, upload-time = "2026-11-03T09:54:01.046Z" },
|
|
1090
|
+
{ url = "https://files.pythonhosted.org/packages/5f/ed/29218597cb38aa9058dffda7906749df9e9da02b4c4da4e88dd8bcfa85eb/pyarrow-26.0.1-cp311-cp311-macosx_12_0_x86_64.whl", hash = "sha256:0187cbe6558cb158e148dd7b779f59cab6104163d148d808d04f293dc897b7ec", size = 39778863, upload-time = "2026-11-03T09:57:58.046Z" },
|
|
1091
|
+
{ url = "https://files.pythonhosted.org/packages/03/f9/44489f525c73cc469f23fd02c0a3009882a8dcf45d0d9fb6ca1bb84a53e2/pyarrow-26.0.1-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:22a96a225de107eb9acd1ad9a818198ca832df2a4c0952412f754a7ed2105a98", size = 51836882, upload-time = "2026-11-03T10:48:50.544Z" },
|
|
1092
|
+
{ url = "https://files.pythonhosted.org/packages/e6/87/6bf528898ef82dc3e8d762cbec7b42ae127a543895cc78c5df26a1f497f5/pyarrow-26.0.1-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:39cb0f2418282c24bea6ceda77b03e5a8f0a5766b63a8bf194d4e2a2c423548c", size = 55016622, upload-time = "2026-11-03T10:48:58.916Z" },
|
|
1093
|
+
{ url = "https://files.pythonhosted.org/packages/97/e8/3b4898693744efb5aa60a859774ee3874a2635b288f309f1afb78a698f38/pyarrow-26.0.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:24350194bc83f1fde74aa321b6b43cd78bfdbfe613a795a6b9145fd4beaf4827", size = 55452257, upload-time = "2026-11-03T10:49:05.872Z" },
|
|
1094
|
+
{ url = "https://files.pythonhosted.org/packages/86/96/bbeb5152a27406c65b80b72ecba4451fea18d549a5aea1fbb2c097d86b08/pyarrow-26.0.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ed1e19bfaf79565b74e3b0a45a0ba6d05620e68d5a5b48a8193c2bbee7cf5484", size = 58605344, upload-time = "2026-11-03T10:49:14.145Z" },
|
|
1095
|
+
{ url = "https://files.pythonhosted.org/packages/bf/aa/afb7321eaed5f65332aa691fcd892bf67d0289e2ba884c8ce592d3188a26/pyarrow-26.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:5f681458e4fb81aefef50d3a8a432fe92f8480a87693616f9d95e95ceac8844c", size = 29034160, upload-time = "2026-11-03T10:49:19.45Z" },
|
|
1096
|
+
{ url = "https://files.pythonhosted.org/packages/61/81/dc5814d61f8c956363e81bcaba61b4712a5d227324d40c766b3858160711/pyarrow-26.0.1-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:217497a51fd41abb74502ba2f4900872e0944c226945c02ee8a1cb4f81df3392", size = 37290209, upload-time = "2026-11-03T10:49:25.185Z" },
|
|
1097
|
+
{ url = "https://files.pythonhosted.org/packages/f7/c8/dcc42b1cceb69ff032fa16430bd82c086b933e35ef05ab521e56313b76be/pyarrow-26.0.1-cp312-cp312-macosx_12_0_x86_64.whl", hash = "sha256:a2c5e9cec45b318917b630dc040cf197aef624d94866ab2c8e709708057123d2", size = 39757493, upload-time = "2026-11-03T10:49:30.886Z" },
|
|
1098
|
+
{ url = "https://files.pythonhosted.org/packages/ab/7e/da9831bfcaaa908ae6d5d049c04c2233a5a7e216d6b961e22861056ef3fd/pyarrow-26.0.1-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:6c18167774fb599d42444b7ac558a893d49e750fb14232b538955e6f0d1d51ea", size = 51818506, upload-time = "2026-11-03T10:49:37.89Z" },
|
|
1099
|
+
{ url = "https://files.pythonhosted.org/packages/d3/79/e2fc9b1317b7a21e7bcd57eb035cac3fe72f47af3efe2ec3b4dea9a08a04/pyarrow-26.0.1-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:c718bf97a92a6dea97fd1062c3b9f9e2e83cb9cc926e752289fa4ffff41738f9", size = 55043763, upload-time = "2026-11-03T10:49:45.732Z" },
|
|
1100
|
+
{ url = "https://files.pythonhosted.org/packages/e3/66/dbe72f5fa21a92b645d56410bacac605defe63e5d3e9794b2fd8c7d77030/pyarrow-26.0.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:40aea57ab8bd3cf35a11e604cd7d0c7436dc90d1ce9b88b6711ef2f1a232968e", size = 55438656, upload-time = "2026-11-03T10:49:53.74Z" },
|
|
1101
|
+
{ url = "https://files.pythonhosted.org/packages/d1/b1/c91322fc4c1800c1f7dd78f911b1dd74187acaeb246d86478a0f064f6af5/pyarrow-26.0.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:73534fbda7f73cab0791b569b93112d4c9e1546cedd0f309d1f69889beb6a08f", size = 58625736, upload-time = "2026-11-03T10:50:01.442Z" },
|
|
1102
|
+
{ url = "https://files.pythonhosted.org/packages/30/61/d94decccacb4dd40a4ebeed0ff3b2cea8f0b680f50184ea7eb0264db779b/pyarrow-26.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:9379f0d1056cad6866c4697aec83a15830202ec7e0bd52f8bd508b316260fa61", size = 29078866, upload-time = "2026-11-03T10:50:06.854Z" },
|
|
1103
|
+
{ url = "https://files.pythonhosted.org/packages/15/b8/c31c51fbe7df901817d88c73eeec25079d0da5f7c7b67fc0bf071f6a2df5/pyarrow-26.0.1-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:4cb739ccb87292c673e1f69819b68432a73bb8bb456e8599641bba9183a8a1dd", size = 37292947, upload-time = "2026-11-03T10:50:12.333Z" },
|
|
1104
|
+
{ url = "https://files.pythonhosted.org/packages/fd/63/0c2559ae33ce59d2ca5ce74117676f8ff8da4cf102729a158ea46415eb50/pyarrow-26.0.1-cp313-cp313-macosx_12_0_x86_64.whl", hash = "sha256:50b40aea92f43b2b6da3427548a5337741b4b93b92e8015a8a3eefc0e75acca2", size = 39767535, upload-time = "2026-11-03T10:50:18.254Z" },
|
|
1105
|
+
{ url = "https://files.pythonhosted.org/packages/31/02/d9462d1ae4e54c3964af38316a802b29c28970b7d375722ef190af736640/pyarrow-26.0.1-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:a3a79661404ba3d41b7c9a45cb56113246a244b38cb1393fadae289bc66b91b4", size = 51815955, upload-time = "2026-11-03T10:50:25.332Z" },
|
|
1106
|
+
{ url = "https://files.pythonhosted.org/packages/96/54/33c2df56948d88a4d83a52999a4a81a4871b2de481ff25ccd6f5ccd2589a/pyarrow-26.0.1-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:f71221bbc7707e3fad920d0478db9350791d4714ec445299ee0d56559fbc156c", size = 55038406, upload-time = "2026-11-03T10:50:32.551Z" },
|
|
1107
|
+
{ url = "https://files.pythonhosted.org/packages/99/57/8e1f886ee96c7edab89ab6f15fbb00c85c2bb2173f3cb504925731d00564/pyarrow-26.0.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:8ccfb9958bcd09f34678c64fb42a0e270b47cd092ae79578da51e0d7bb144296", size = 55437362, upload-time = "2026-11-03T10:50:39.89Z" },
|
|
1108
|
+
{ url = "https://files.pythonhosted.org/packages/8c/c3/d87939a5f6cd30bb406bad6c20926fcedafc52ec5629f6eb27e4cd5db709/pyarrow-26.0.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:029e881af986375a2731da79c999fe734a72547fabb16503d65fc079d4bc7eb2", size = 58618865, upload-time = "2026-11-03T10:50:48.029Z" },
|
|
1109
|
+
{ url = "https://files.pythonhosted.org/packages/c1/9e/b6c8afec2ffc06bbd00a88326826f9d66e4bbca752c0837ee8e2dbf2238f/pyarrow-26.0.1-cp313-cp313-win_amd64.whl", hash = "sha256:8196f36a2f4cb8d2d6ef3651941b80e5ccf125d7653657d99af5bb298e7a7026", size = 28989592, upload-time = "2026-11-03T10:50:53.384Z" },
|
|
1110
|
+
{ url = "https://files.pythonhosted.org/packages/de/48/999f6e30323e2e95a4439180b62f6308023970e4a37d31497080ea2a1a78/pyarrow-26.0.1-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:15435b595c14583f6ac8495c3ef89ac3fed6bc94f168467bfd3b6ba53ad3a643", size = 37334639, upload-time = "2026-11-03T10:50:59.462Z" },
|
|
1111
|
+
{ url = "https://files.pythonhosted.org/packages/7f/3a/4458972c69ead95af5d3b701c80885133c351075895382499df49ed92d36/pyarrow-26.0.1-cp314-cp314-macosx_12_0_x86_64.whl", hash = "sha256:a44a244867cac106cd326dd0a04be0850d2b8af3b1418ed7aeb8146d13aba360", size = 39802150, upload-time = "2026-11-03T10:51:05.743Z" },
|
|
1112
|
+
{ url = "https://files.pythonhosted.org/packages/86/d0/fa4bc5d66f78cbc4ec8482b210c2fc3b8cb59564efe171f3ca9be416f8ee/pyarrow-26.0.1-cp314-cp314-manylinux_2_28_aarch64.whl", hash = "sha256:0044cb9303c3ae082cc52a2493312109c955bcfa84e87be768736f7d6d8f6257", size = 51880097, upload-time = "2026-11-03T10:51:12.75Z" },
|
|
1113
|
+
{ url = "https://files.pythonhosted.org/packages/f3/57/755a1b54d37c2a9e2c283d8bc648a50aa4ce57f977ce6a4b1d65eba29f51/pyarrow-26.0.1-cp314-cp314-manylinux_2_28_x86_64.whl", hash = "sha256:7ae48ab53610b85e004b03bccff593fbdf22186d0ab48ed42c90797915dac814", size = 55063542, upload-time = "2026-11-03T10:51:20.417Z" },
|
|
1114
|
+
{ url = "https://files.pythonhosted.org/packages/45/ba/7cd1d78c2ef5a36b1f8d137d1790179875639f197ed90702268084a2470a/pyarrow-26.0.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:a97df0c52c966ae8970ac0899ae75d81083c5400eca267de2608ca0f13e6e118", size = 55490507, upload-time = "2026-11-03T10:51:28.295Z" },
|
|
1115
|
+
{ url = "https://files.pythonhosted.org/packages/9f/02/39e18c5381ad908d7161cc16a02dce03b3db236d3c3ac99fc020878287fb/pyarrow-26.0.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5f665e73790222779613ae3d23d2a1d72f0f13a4646862277e9784bb46e14fca", size = 58648328, upload-time = "2026-11-03T10:51:36.303Z" },
|
|
1116
|
+
{ url = "https://files.pythonhosted.org/packages/1c/18/2cd453cc2e282d465e9c9b60834d6ca17601dc08e2d402751cb40af92356/pyarrow-26.0.1-cp314-cp314-win_amd64.whl", hash = "sha256:492dc499097968e51cac46e03e0054c68dd3c5f39d75098343f5ad05ec79f7df", size = 29757743, upload-time = "2026-11-03T10:52:35.061Z" },
|
|
1117
|
+
{ url = "https://files.pythonhosted.org/packages/db/46/b97f117adb46f93620aa94bf13747a81ccc5e099be534cc195c94b281ba7/pyarrow-26.0.1-cp314-cp314t-macosx_12_0_arm64.whl", hash = "sha256:ec196b35270263eda71fc3f43bd31a89b778c6787f19872df5abb9d4264057ff", size = 37452099, upload-time = "2026-11-03T10:51:42.419Z" },
|
|
1118
|
+
{ url = "https://files.pythonhosted.org/packages/a6/40/ac1796654fc8591049d200f6bcd646a2319509010784f47c1cf6b09d1000/pyarrow-26.0.1-cp314-cp314t-macosx_12_0_x86_64.whl", hash = "sha256:8af2b4e004dc18da8dc77bce27d97c675d2f71348e3ade2741cecac85c3f0c21", size = 39888805, upload-time = "2026-11-03T10:51:48.766Z" },
|
|
1119
|
+
{ url = "https://files.pythonhosted.org/packages/6c/93/bcff79148416896738a707992570c4ae8e3bb087bc9e0dca8df7dbf6e983/pyarrow-26.0.1-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:c2bf4444a7e86f109dc03e28b2c98eb6671e2eb95e6057c25043d25684e337e9", size = 51884587, upload-time = "2026-11-03T10:51:56.701Z" },
|
|
1120
|
+
{ url = "https://files.pythonhosted.org/packages/fa/62/cb05e81d31cd1dc97c2e16151425e61fe3a19274ccd1254cafab3a173f96/pyarrow-26.0.1-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:b121de63e2f92704b6b9881fbe69cb3eeca786ea882379b59ce80b8012c1bd8c", size = 55018252, upload-time = "2026-11-03T10:52:05.813Z" },
|
|
1121
|
+
{ url = "https://files.pythonhosted.org/packages/f8/f5/e8dbbb803bb28a32411491d502679e272c569af7f590816327e84725c748/pyarrow-26.0.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:40b9c1a5841559030ba8d1b8c15d6160bccb702ff2596b4ce296e1efd7665781", size = 55522075, upload-time = "2026-11-03T10:52:14.577Z" },
|
|
1122
|
+
{ url = "https://files.pythonhosted.org/packages/9b/7a/5000d6082b116359d3db3ee6073a8f708f41cb4bb7d6414f94cd40a90fe7/pyarrow-26.0.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:9519f70bd847f7628a2d16324d1ea8827e2ec1da347ee0bf96cc7c248195e923", size = 58625604, upload-time = "2026-11-03T10:52:23.045Z" },
|
|
1123
|
+
{ url = "https://files.pythonhosted.org/packages/41/70/74a5a07eeee1a84cd51e81813b7fd2d5ffc90192a95981a51e97a8ced99e/pyarrow-26.0.1-cp314-cp314t-win_amd64.whl", hash = "sha256:6d9b558e1bce3270f1f422c61fd682615cfb34ffd320a51e765e868e8c155a72", size = 29925653, upload-time = "2026-11-03T10:52:29.188Z" },
|
|
1124
|
+
{ url = "https://files.pythonhosted.org/packages/77/09/4e9461479930e3f4367cc0b4f4356d4444a23be9cb350272b159cd0c7fa9/pyarrow-26.0.1-cp315-cp315-macosx_12_0_arm64.whl", hash = "sha256:2c118754a0abe0bf20ef17432f95534ebb0ded37a48b6e8690cdd02625a86d97", size = 37329458, upload-time = "2026-11-03T10:52:41.622Z" },
|
|
1125
|
+
{ url = "https://files.pythonhosted.org/packages/40/5a/9e44840924b0939defacc2561e54dc9aba10eff1fc5dadcf41921202d99f/pyarrow-26.0.1-cp315-cp315-macosx_12_0_x86_64.whl", hash = "sha256:99574d8eabad06cc4bb3fed327b298c8a44a3596abd2d575738fa019df7ac59e", size = 39799948, upload-time = "2026-11-03T10:52:47.507Z" },
|
|
1126
|
+
{ url = "https://files.pythonhosted.org/packages/70/3a/5fe40369653a082d86fdb6ce2b7c40a4ef435d90a68da60c05dda0c554fc/pyarrow-26.0.1-cp315-cp315-manylinux_2_28_aarch64.whl", hash = "sha256:12c5edbdf9b8a0f121a0a222be150c3a711149bc4322736d6a04693fbfd8c723", size = 51875337, upload-time = "2026-11-03T10:52:54.59Z" },
|
|
1127
|
+
{ url = "https://files.pythonhosted.org/packages/5e/87/f768a458cf975c17c73912fb25a1e0693ceef8d76d78cf83ffdf1f63ec70/pyarrow-26.0.1-cp315-cp315-manylinux_2_28_x86_64.whl", hash = "sha256:8cb5bcfe627ee6b910fbec27871d38cf4f28f331ea6328902ce6a6272851ac70", size = 55060370, upload-time = "2026-11-03T10:53:02.19Z" },
|
|
1128
|
+
{ url = "https://files.pythonhosted.org/packages/e0/30/280c24a7da9085b782cd6960ccae6763b0170f51385b9122385c12226ff2/pyarrow-26.0.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:e2ee5f01f84996109405759cba8bb92a16455c50deb6526a535ab3b8d5f4e326", size = 55488705, upload-time = "2026-11-03T10:53:09.8Z" },
|
|
1129
|
+
{ url = "https://files.pythonhosted.org/packages/42/e7/8e7b7f7bd58c88fd8da93db0d0869c69175c3ddccf365afbcc13fbd691da/pyarrow-26.0.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:e25d4a886868c5ce136d194f308bd690e1335aebf6b8bcae3511b0becdb3a65a", size = 58646822, upload-time = "2026-11-03T10:53:17.902Z" },
|
|
1130
|
+
{ url = "https://files.pythonhosted.org/packages/3b/c7/6094fa2c0b5602d81b1177ac7f5b2de8a386862d08e57a75931da774f3e0/pyarrow-26.0.1-cp315-cp315-win_amd64.whl", hash = "sha256:6cdad5f67a30bbcea54c3c2a27ea45bd5a170377bf45f80f4d7e3a726e8e3283", size = 29755706, upload-time = "2026-11-03T10:54:14.582Z" },
|
|
1131
|
+
{ url = "https://files.pythonhosted.org/packages/41/0f/86747650c8218bcea7443884e7c8ba9d3fe9a13fb5a4be99acdd5c2b9144/pyarrow-26.0.1-cp315-cp315t-macosx_12_0_arm64.whl", hash = "sha256:12dc85cec96aa62d429d7c43749c072e9330c373b67d6ee458edeef444c8941f", size = 37445268, upload-time = "2026-11-03T10:53:25.531Z" },
|
|
1132
|
+
{ url = "https://files.pythonhosted.org/packages/b9/ec/4159b2362267009b754a7c2f138f16bdfd6623b308005678eb7cf1b65863/pyarrow-26.0.1-cp315-cp315t-macosx_12_0_x86_64.whl", hash = "sha256:52e4daba8f1b4316b7b9ba7e84903a339cbc52998ebddc9a7c78b5ea37c23bbb", size = 39877540, upload-time = "2026-11-03T10:53:33.046Z" },
|
|
1133
|
+
{ url = "https://files.pythonhosted.org/packages/a8/0e/df0501e93eef78402f94f33f948aba996181b3d3c54f97a3f16544916d05/pyarrow-26.0.1-cp315-cp315t-manylinux_2_28_aarch64.whl", hash = "sha256:322f6fc80c6db1ec87c9d905df3ce259cd22e922f47fbad3c58d0dd6f63bc7a9", size = 51874165, upload-time = "2026-11-03T10:53:41.281Z" },
|
|
1134
|
+
{ url = "https://files.pythonhosted.org/packages/fb/30/0d43bf6a49fca51142a96c73d693ec34d229c902a46e007c25f3b9798b52/pyarrow-26.0.1-cp315-cp315t-manylinux_2_28_x86_64.whl", hash = "sha256:68b91f34e3424d55564e9d4d4f7491aaebd6db3998039cc33ba795a63167f04e", size = 55012741, upload-time = "2026-11-03T10:53:49.153Z" },
|
|
1135
|
+
{ url = "https://files.pythonhosted.org/packages/ae/ff/0e6cd73832d97c3852284eda9bee2428c53a92bcf6f6aa4bda1e15314a59/pyarrow-26.0.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:b801300d65859adaf611c9c0a4cb39bd3cb1713b60b974ad20650a8a0f8af2fd", size = 55512474, upload-time = "2026-11-03T10:53:56.512Z" },
|
|
1136
|
+
{ url = "https://files.pythonhosted.org/packages/f0/1e/43cdcf9719169f0228b3e516e5004ed0acfc3a4c70ce35e3f2a80a485baf/pyarrow-26.0.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:2623b6c20637c0e2c40be96bda3d127dde49d6e6734ad6e71df91a013e40a3c4", size = 58616300, upload-time = "2026-11-03T10:54:04.472Z" },
|
|
1137
|
+
{ url = "https://files.pythonhosted.org/packages/df/bf/8e29b47c61fc961e92e96db129d5dc7b716c2091dfe05359e70f20d712b9/pyarrow-26.0.1-cp315-cp315t-win_amd64.whl", hash = "sha256:55b1d871f21c8ed249c93f7375a35c35aa9b7b3af6896405cb8a6b67ad9bc7f9", size = 29909417, upload-time = "2026-11-03T10:54:09.613Z" },
|
|
1138
|
+
]
|
|
1139
|
+
|
|
1081
1140
|
[[package]]
|
|
1082
1141
|
name = "pycountry"
|
|
1083
1142
|
version = "26.2.16"
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"""Build a SQLite database from station files."""
|
|
2
|
-
|
|
3
|
-
import sqlite3
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
from typing import Any
|
|
6
|
-
|
|
7
|
-
TABLES_SQL = """
|
|
8
|
-
CREATE TABLE `stations` (
|
|
9
|
-
`id` char(5) NOT NULL PRIMARY KEY,
|
|
10
|
-
`country` varchar(2) DEFAULT NULL,
|
|
11
|
-
`region` varchar(5) DEFAULT NULL,
|
|
12
|
-
`latitude` float(8,4) DEFAULT NULL,
|
|
13
|
-
`longitude` float(8,4) DEFAULT NULL,
|
|
14
|
-
`elevation` int(4) DEFAULT NULL,
|
|
15
|
-
`timezone` varchar(30) DEFAULT NULL
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
CREATE TABLE `names` (
|
|
19
|
-
`station` char(5) NOT NULL,
|
|
20
|
-
`language` char(2) NOT NULL,
|
|
21
|
-
`name` varchar(255) NOT NULL,
|
|
22
|
-
PRIMARY KEY (`station`, `language`)
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
CREATE TABLE `identifiers` (
|
|
26
|
-
`station` char(5) NOT NULL,
|
|
27
|
-
`key` varchar(255) NOT NULL,
|
|
28
|
-
`value` varchar(255) NOT NULL,
|
|
29
|
-
PRIMARY KEY (`station`, `key`)
|
|
30
|
-
);
|
|
31
|
-
"""
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def build_database(
|
|
35
|
-
stations: dict[str, dict[str, Any]], output: Path
|
|
36
|
-
) -> tuple[int, list[tuple[str, str]]]:
|
|
37
|
-
"""Write stations to a new SQLite database at ``output``.
|
|
38
|
-
|
|
39
|
-
Inactive stations are left out, like in the official database. The file is
|
|
40
|
-
only replaced once the database was built successfully.
|
|
41
|
-
|
|
42
|
-
Returns the number of stations written and a list of (id, reason) for
|
|
43
|
-
stations which could not be written.
|
|
44
|
-
"""
|
|
45
|
-
output.parent.mkdir(parents=True, exist_ok=True)
|
|
46
|
-
tmp = output.with_name(f"{output.name}.tmp")
|
|
47
|
-
tmp.unlink(missing_ok=True)
|
|
48
|
-
|
|
49
|
-
count = 0
|
|
50
|
-
failed: list[tuple[str, str]] = []
|
|
51
|
-
conn = sqlite3.connect(tmp, isolation_level=None)
|
|
52
|
-
try:
|
|
53
|
-
conn.executescript(TABLES_SQL)
|
|
54
|
-
conn.execute("BEGIN")
|
|
55
|
-
for station_id, data in stations.items():
|
|
56
|
-
if data.get("active", True) is False:
|
|
57
|
-
continue
|
|
58
|
-
# Roll back partial inserts of stations which can't be written
|
|
59
|
-
conn.execute("SAVEPOINT station")
|
|
60
|
-
try:
|
|
61
|
-
_insert(conn, data)
|
|
62
|
-
count += 1
|
|
63
|
-
except (KeyError, TypeError, AttributeError, sqlite3.Error) as exc:
|
|
64
|
-
conn.execute("ROLLBACK TO station")
|
|
65
|
-
failed.append((station_id, _describe(exc)))
|
|
66
|
-
conn.execute("RELEASE station")
|
|
67
|
-
conn.execute("COMMIT")
|
|
68
|
-
finally:
|
|
69
|
-
conn.close()
|
|
70
|
-
|
|
71
|
-
tmp.replace(output)
|
|
72
|
-
return count, failed
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def _insert(conn: sqlite3.Connection, data: dict[str, Any]) -> None:
|
|
76
|
-
station_id = data["id"]
|
|
77
|
-
location = data["location"]
|
|
78
|
-
conn.execute(
|
|
79
|
-
"INSERT INTO `stations` VALUES (?, ?, ?, ?, ?, ?, ?)",
|
|
80
|
-
(
|
|
81
|
-
station_id,
|
|
82
|
-
data["country"],
|
|
83
|
-
data.get("region"),
|
|
84
|
-
location["latitude"],
|
|
85
|
-
location["longitude"],
|
|
86
|
-
location["elevation"],
|
|
87
|
-
data["timezone"],
|
|
88
|
-
),
|
|
89
|
-
)
|
|
90
|
-
conn.executemany(
|
|
91
|
-
"INSERT INTO `names` VALUES (?, ?, ?)",
|
|
92
|
-
[(station_id, lang, name) for lang, name in data["name"].items()],
|
|
93
|
-
)
|
|
94
|
-
conn.executemany(
|
|
95
|
-
"INSERT INTO `identifiers` VALUES (?, ?, ?)",
|
|
96
|
-
[(station_id, key, value) for key, value in data["identifiers"].items()],
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
def _describe(exc: Exception) -> str:
|
|
101
|
-
if isinstance(exc, KeyError):
|
|
102
|
-
return f"Missing property {exc}"
|
|
103
|
-
return f"Could not be written: {exc}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|