Spaces:
Running
Running
| # src/ingestion/file_detector.py | |
| from pathlib import Path | |
| from typing import Optional | |
| def detect_file_type(path: str) -> Optional[str]: | |
| """ | |
| Returns one of: 'tcx', 'gpx', 'fit' or None if unknown. | |
| Accepts compressed (.gz) variants. | |
| """ | |
| p = Path(path) | |
| name = p.name.lower() | |
| if name.endswith(".tcx") or name.endswith(".tcx.gz"): | |
| return "tcx" | |
| if name.endswith(".gpx") or name.endswith(".gpx.gz"): | |
| return "gpx" | |
| if name.endswith(".fit") or name.endswith(".fit.gz"): | |
| return "fit" | |
| return None | |