Generate tfl client
This commit is contained in:
parent
caf943ed06
commit
a7cc4d9b2b
5 changed files with 1274 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
|||
data_sources
|
||||
.venv
|
||||
.claude
|
||||
.claude
|
||||
tfl_journey_client
|
||||
|
|
|
|||
1170
Journey.yaml
Normal file
1170
Journey.yaml
Normal file
File diff suppressed because it is too large
Load diff
43
generate_tfl_client.py
Normal file
43
generate_tfl_client.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env python3
|
||||
# /// script
|
||||
# requires-python = ">=3.12"
|
||||
# dependencies = ["openapi-python-client"]
|
||||
# ///
|
||||
"""Regenerate the TfL Journey API client from the OpenAPI specification."""
|
||||
|
||||
# Run it with:
|
||||
# uv run generate_tfl_client.py
|
||||
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
OPENAPI_SPEC = Path("Journey.yaml")
|
||||
OUTPUT_PATH = Path("tfl_journey_client")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if not OPENAPI_SPEC.exists():
|
||||
raise FileNotFoundError(f"OpenAPI spec not found: {OPENAPI_SPEC}")
|
||||
|
||||
# Remove existing client if present
|
||||
if OUTPUT_PATH.exists():
|
||||
print(f"Removing existing client at {OUTPUT_PATH}")
|
||||
shutil.rmtree(OUTPUT_PATH)
|
||||
|
||||
# Generate the client
|
||||
print(f"Generating client from {OPENAPI_SPEC}")
|
||||
result = subprocess.run(
|
||||
["openapi-python-client", "generate", "--path", str(OPENAPI_SPEC), "--output-path", str(OUTPUT_PATH)],
|
||||
check=True,
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
print(f"Client generated successfully at {OUTPUT_PATH}")
|
||||
else:
|
||||
print("Client generation failed")
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -5,8 +5,14 @@ description = "Add your description here"
|
|||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"attrs>=22.2.0",
|
||||
"httpx>=0.28.1",
|
||||
"journey-client",
|
||||
"plotly>=6.5.2",
|
||||
"polars>=1.37.1",
|
||||
"python-dateutil>=2.8.0",
|
||||
"tqdm>=4.67.1",
|
||||
]
|
||||
|
||||
[tool.uv.sources]
|
||||
journey-client = { path = "./tfl_journey_client" }
|
||||
|
|
|
|||
53
uv.lock
generated
53
uv.lock
generated
|
|
@ -15,6 +15,15 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/38/0e/27be9fdef66e72d64c0cdc3cc2823101b80585f8119b5c112c2e8f5f7dab/anyio-4.12.1-py3-none-any.whl", hash = "sha256:d405828884fc140aa80a3c667b8beed277f1dfedec42ba031bd6ac3db606ab6c", size = 113592, upload-time = "2026-01-06T11:45:19.497Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "attrs"
|
||||
version = "25.4.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/6b/5c/685e6633917e101e5dcb62b9dd76946cbb57c26e133bae9e0cd36033c0a9/attrs-25.4.0.tar.gz", hash = "sha256:16d5969b87f0859ef33a48b35d55ac1be6e42ae49d5e853b597db70c35c57e11", size = 934251, upload-time = "2025-10-06T13:54:44.725Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/3a/2a/7cc015f5b9f5db42b7d48157e23356022889fc354a2813c15934b7cb5c0e/attrs-25.4.0-py3-none-any.whl", hash = "sha256:adcf7e2a1fb3b36ac48d97835bb6d8ade15b8dcce26aba8bf1d14847b57a3373", size = 67615, upload-time = "2025-10-06T13:54:43.17Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "certifi"
|
||||
version = "2026.1.4"
|
||||
|
|
@ -79,6 +88,23 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "journey-client"
|
||||
version = "1.0"
|
||||
source = { directory = "tfl_journey_client" }
|
||||
dependencies = [
|
||||
{ name = "attrs" },
|
||||
{ name = "httpx" },
|
||||
{ name = "python-dateutil" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "attrs", specifier = ">=22.2.0" },
|
||||
{ name = "httpx", specifier = ">=0.23.0,<0.29.0" },
|
||||
{ name = "python-dateutil", specifier = ">=2.8.0,<3.0.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "narwhals"
|
||||
version = "2.15.0"
|
||||
|
|
@ -143,20 +169,47 @@ name = "property-map"
|
|||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
dependencies = [
|
||||
{ name = "attrs" },
|
||||
{ name = "httpx" },
|
||||
{ name = "journey-client" },
|
||||
{ name = "plotly" },
|
||||
{ name = "polars" },
|
||||
{ name = "python-dateutil" },
|
||||
{ name = "tqdm" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "attrs", specifier = ">=22.2.0" },
|
||||
{ name = "httpx", specifier = ">=0.28.1" },
|
||||
{ name = "journey-client", directory = "tfl_journey_client" },
|
||||
{ name = "plotly", specifier = ">=6.5.2" },
|
||||
{ name = "polars", specifier = ">=1.37.1" },
|
||||
{ name = "python-dateutil", specifier = ">=2.8.0" },
|
||||
{ name = "tqdm", specifier = ">=4.67.1" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "python-dateutil"
|
||||
version = "2.9.0.post0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "six" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", size = 342432, upload-time = "2024-03-01T18:36:20.211Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload-time = "2024-03-01T18:36:18.57Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "six"
|
||||
version = "1.17.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031, upload-time = "2024-12-04T17:35:28.174Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tqdm"
|
||||
version = "4.67.1"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue