trying to get sub label showed properly

This commit is contained in:
Davide Scaini
2026-03-30 20:09:01 +02:00
parent c58bc8f7d5
commit 877472e620
11 changed files with 157 additions and 24 deletions
+5 -4
View File
@@ -8,7 +8,7 @@ import gpxpy.gpx
from bincio.extract.models import DataPoint, ParsedActivity
from bincio.extract.parsers.base import BaseParser
from bincio.extract.sport import normalise_sport
from bincio.extract.sport import normalise_sport, normalise_sub_sport
# Known GPX extension namespaces
_NS_GARMIN = "http://www.garmin.com/xmlschemas/TrackPointExtension/v1"
@@ -41,14 +41,15 @@ class GpxParser(BaseParser):
if not points:
raise ValueError(f"No trackpoints found in {path.name}")
sport = normalise_sport(
(gpx.tracks[0].type if gpx.tracks else None) or "cycling"
)
raw_sport = (gpx.tracks[0].type if gpx.tracks else None) or "cycling"
sport = normalise_sport(raw_sport)
sub_sport = normalise_sub_sport(raw_sport)
started_at = points[0].timestamp
return ParsedActivity(
points=points,
sport=sport,
sub_sport=sub_sport,
started_at=started_at,
source_file=path.name,
source_hash="", # set by factory