From 52a4b52628c1390a892659f1945a2011b5d25ec1 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 6 Aug 2025 14:07:02 -0700 Subject: [PATCH] FileName clean up (#35938) two spaces! --- tools/lib/logreader.py | 11 ++++++----- tools/lib/route.py | 18 +++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/tools/lib/logreader.py b/tools/lib/logreader.py index fa6e6357eb..5915f1dde3 100755 --- a/tools/lib/logreader.py +++ b/tools/lib/logreader.py @@ -102,7 +102,8 @@ class ReadMode(enum.StrEnum): LogPath = str | None -Source = Callable[[SegmentRange, tuple[str, ...]], list[LogPath]] +LogFileName = tuple[str, ...] +Source = Callable[[SegmentRange, LogFileName], list[LogPath]] InternalUnavailableException = Exception("Internal source not available") @@ -111,7 +112,7 @@ class LogsUnavailable(Exception): pass -def comma_api_source(sr: SegmentRange, fns: tuple[str, ...]) -> list[LogPath]: +def comma_api_source(sr: SegmentRange, fns: LogFileName) -> list[LogPath]: route = Route(sr.route_name) # comma api will have already checked if the file exists @@ -121,7 +122,7 @@ def comma_api_source(sr: SegmentRange, fns: tuple[str, ...]) -> list[LogPath]: return [route.qlog_paths()[seg] for seg in sr.seg_idxs] -def internal_source(sr: SegmentRange, fns: tuple[str, ...], endpoint_url: str = DATA_ENDPOINT) -> list[LogPath]: +def internal_source(sr: SegmentRange, fns: LogFileName, endpoint_url: str = DATA_ENDPOINT) -> list[LogPath]: if not internal_source_available(endpoint_url): raise InternalUnavailableException @@ -131,11 +132,11 @@ def internal_source(sr: SegmentRange, fns: tuple[str, ...], endpoint_url: str = return eval_source([[get_internal_url(sr, seg, fn) for fn in fns] for seg in sr.seg_idxs]) -def openpilotci_source(sr: SegmentRange, fns: tuple[str, ...]) -> list[LogPath]: +def openpilotci_source(sr: SegmentRange, fns: LogFileName) -> list[LogPath]: return eval_source([[get_url(sr.route_name, seg, fn) for fn in fns] for seg in sr.seg_idxs]) -def comma_car_segments_source(sr: SegmentRange, fns: tuple[str, ...]) -> list[LogPath]: +def comma_car_segments_source(sr: SegmentRange, fns: LogFileName) -> list[LogPath]: return eval_source([get_comma_segments_url(sr.route_name, seg) for seg in sr.seg_idxs]) diff --git a/tools/lib/route.py b/tools/lib/route.py index dc8bb60e8f..882585a151 100644 --- a/tools/lib/route.py +++ b/tools/lib/route.py @@ -1,7 +1,6 @@ import os import re import requests -from typing import TypeAlias from functools import cache from urllib.parse import urlparse from collections import defaultdict @@ -11,15 +10,16 @@ from openpilot.tools.lib.auth_config import get_token from openpilot.tools.lib.api import APIError, CommaApi from openpilot.tools.lib.helpers import RE -FileNameTuple: TypeAlias = tuple[str, ...] + class FileName: - RLOG: FileNameTuple = ("rlog.zst", "rlog.bz2") - QLOG: FileNameTuple = ("qlog.zst", "qlog.bz2") - QCAMERA: FileNameTuple = ('qcamera.ts',) - FCAMERA: FileNameTuple = ('fcamera.hevc',) - ECAMERA: FileNameTuple = ('ecamera.hevc',) - DCAMERA: FileNameTuple = ('dcamera.hevc',) - BOOTLOG: FileNameTuple = ('bootlog.zst', 'bootlog.bz2') + RLOG = ("rlog.zst", "rlog.bz2") + QLOG = ("qlog.zst", "qlog.bz2") + QCAMERA = ('qcamera.ts',) + FCAMERA = ('fcamera.hevc',) + ECAMERA = ('ecamera.hevc',) + DCAMERA = ('dcamera.hevc',) + BOOTLOG = ('bootlog.zst', 'bootlog.bz2') + class Route: def __init__(self, name, data_dir=None):