runner-ai-intelligence / src /ingestion /file_detector.py
avfranco's picture
HF Space deploy snapshot (minimal allow-list)
d64fd55
# 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