All good
This commit is contained in:
parent
6ea544a0f6
commit
6cc7288126
45 changed files with 929 additions and 1043 deletions
|
|
@ -36,6 +36,8 @@ from pathlib import Path
|
|||
|
||||
from tqdm import tqdm
|
||||
|
||||
from pipeline.local_temp import local_tmp_dir
|
||||
|
||||
ENGLAND_PBF_URL = (
|
||||
"https://download.geofabrik.de/europe/united-kingdom/england-latest.osm.pbf"
|
||||
)
|
||||
|
|
@ -164,7 +166,10 @@ def clean_gtfs(src: Path, dst: Path) -> None:
|
|||
)
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(
|
||||
mode="wb", delete=False, suffix=".txt"
|
||||
mode="wb",
|
||||
delete=False,
|
||||
suffix=".txt",
|
||||
dir=local_tmp_dir(),
|
||||
)
|
||||
tmp.write(header)
|
||||
|
||||
|
|
@ -388,7 +393,10 @@ def convert_high_freq_to_frequency_based(
|
|||
trip_id_idx = cols.index("trip_id")
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(
|
||||
mode="wb", delete=False, suffix=".txt"
|
||||
mode="wb",
|
||||
delete=False,
|
||||
suffix=".txt",
|
||||
dir=local_tmp_dir(),
|
||||
)
|
||||
tmp.write(header)
|
||||
for line in f:
|
||||
|
|
@ -408,7 +416,10 @@ def convert_high_freq_to_frequency_based(
|
|||
trip_id_idx = cols.index("trip_id")
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(
|
||||
mode="wb", delete=False, suffix=".txt"
|
||||
mode="wb",
|
||||
delete=False,
|
||||
suffix=".txt",
|
||||
dir=local_tmp_dir(),
|
||||
)
|
||||
tmp.write(header)
|
||||
for line in f:
|
||||
|
|
@ -451,8 +462,8 @@ def download_tfl_transxchange(raw_dir: Path) -> Path:
|
|||
|
||||
|
||||
def download_naptan() -> None:
|
||||
"""Download NaPTAN stops to /tmp/Stops.csv (needed by transxchange2gtfs)."""
|
||||
dest = Path("/tmp/Stops.csv")
|
||||
"""Download NaPTAN stops to the local temp dir for transxchange2gtfs."""
|
||||
dest = local_tmp_dir() / "Stops.csv"
|
||||
if dest.exists():
|
||||
print(f"NaPTAN Stops.csv already exists: {dest}")
|
||||
return
|
||||
|
|
@ -661,7 +672,10 @@ def clean_national_rail_gtfs(src: Path, dst: Path) -> None:
|
|||
)
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(
|
||||
mode="wb", delete=False, suffix=".txt"
|
||||
mode="wb",
|
||||
delete=False,
|
||||
suffix=".txt",
|
||||
dir=local_tmp_dir(),
|
||||
)
|
||||
tmp.write(header)
|
||||
|
||||
|
|
@ -718,7 +732,10 @@ def clean_national_rail_gtfs(src: Path, dst: Path) -> None:
|
|||
lon_idx = cols.index("stop_lon")
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(
|
||||
mode="wb", delete=False, suffix=".txt"
|
||||
mode="wb",
|
||||
delete=False,
|
||||
suffix=".txt",
|
||||
dir=local_tmp_dir(),
|
||||
)
|
||||
tmp.write(header)
|
||||
|
||||
|
|
@ -749,7 +766,10 @@ def clean_national_rail_gtfs(src: Path, dst: Path) -> None:
|
|||
rt_idx = cols.index("route_type")
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(
|
||||
mode="wb", delete=False, suffix=".txt"
|
||||
mode="wb",
|
||||
delete=False,
|
||||
suffix=".txt",
|
||||
dir=local_tmp_dir(),
|
||||
)
|
||||
tmp.write(header)
|
||||
|
||||
|
|
@ -774,7 +794,10 @@ def clean_national_rail_gtfs(src: Path, dst: Path) -> None:
|
|||
trip_id_idx = cols.index("trip_id")
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(
|
||||
mode="wb", delete=False, suffix=".txt"
|
||||
mode="wb",
|
||||
delete=False,
|
||||
suffix=".txt",
|
||||
dir=local_tmp_dir(),
|
||||
)
|
||||
tmp.write(header)
|
||||
|
||||
|
|
@ -797,7 +820,10 @@ def clean_national_rail_gtfs(src: Path, dst: Path) -> None:
|
|||
end_idx = cols.index("end_date")
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(
|
||||
mode="wb", delete=False, suffix=".txt"
|
||||
mode="wb",
|
||||
delete=False,
|
||||
suffix=".txt",
|
||||
dir=local_tmp_dir(),
|
||||
)
|
||||
tmp.write(header)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue