From ce2a42c45a051e926185a416c9641b6fd061b0aa Mon Sep 17 00:00:00 2001 From: Sean Breckenridge Date: Thu, 16 Feb 2023 02:28:44 -0800 Subject: [PATCH] gpslogger: sort input by splitting on device id --- my/location/gpslogger.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/my/location/gpslogger.py b/my/location/gpslogger.py index 0cd56b3..46fc381 100644 --- a/my/location/gpslogger.py +++ b/my/location/gpslogger.py @@ -32,9 +32,16 @@ from .common import Location logger = LazyLogger(__name__, level="warning") +def _input_sort_key(path: Path) -> str: + if "_" in path.name: + return path.name.split("_", maxsplit=1)[1] + return path.name + def inputs() -> Sequence[Path]: - return get_files(config.export_path, glob="*.gpx") + # gpslogger files can optionally be prefixed by a device id, + # like b5760c66102a5269_20211214142156.gpx + return sorted(get_files(config.export_path, glob="*.gpx", sort=False), key=_input_sort_key) def _cachew_depends_on() -> List[float]: