"""Базовый класс для парсеров GPS-источников (ET-008).""" from src.api.gps_tracks.models import ACTIVITY_TYPES class SourceParser: """Базовый класс для всех парсеров GPS-источников.""" MAPPING: dict = {} # source-category → ACTIVITY_TYPE def __init__(self, source_config: dict): self.config = source_config def map_activity(self, raw_category: str) -> str: """Маппит категорию источника в ACTIVITY_TYPES enum.""" if not raw_category: return "other" mapped = self.MAPPING.get(raw_category.lower(), "other") if mapped not in ACTIVITY_TYPES: return "other" return mapped async def collect(self, bbox: tuple, ctx: dict): """Асинхронный генератор треков. Реализуется в наследниках. Args: bbox: (west, south, east, north) ctx: контекст выполнения (db conn, logger, etc.) Yields: TrackInsert объекты """ raise NotImplementedError return yield # make it a generator