refactor: simplify stage plan return type and enhance test coverage for OSM refresh
This commit is contained in:
@@ -93,7 +93,7 @@ def build_argument_parser() -> argparse.ArgumentParser:
|
||||
return parser
|
||||
|
||||
|
||||
def _build_stage_plan(args: argparse.Namespace) -> tuple[list[Stage], Path, Path]:
|
||||
def _build_stage_plan(args: argparse.Namespace) -> list[Stage]:
|
||||
station_json = args.stations_json or args.output_dir / "osm_stations.json"
|
||||
track_json = args.tracks_json or args.output_dir / "osm_tracks.json"
|
||||
|
||||
@@ -145,7 +145,7 @@ def _build_stage_plan(args: argparse.Namespace) -> tuple[list[Stage], Path, Path
|
||||
)
|
||||
)
|
||||
|
||||
return stages, station_json, track_json
|
||||
return stages
|
||||
|
||||
|
||||
def _describe_plan(stages: Sequence[Stage]) -> None:
|
||||
@@ -183,19 +183,13 @@ def main(argv: list[str] | None = None) -> int:
|
||||
parser = build_argument_parser()
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
stages, station_json, track_json = _build_stage_plan(args)
|
||||
stages = _build_stage_plan(args)
|
||||
|
||||
if args.dry_run:
|
||||
print("Dry run: the following stages would run in order.")
|
||||
_describe_plan(stages)
|
||||
return 0
|
||||
|
||||
# Ensure parent directories exist when we plan to write files.
|
||||
if not args.skip_station_import:
|
||||
station_json.parent.mkdir(parents=True, exist_ok=True)
|
||||
if not args.skip_track_import:
|
||||
track_json.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for stage in stages:
|
||||
_execute_stage(stage)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user