diff --git a/wizard/parsers/parser_gps.py b/wizard/parsers/parser_gps.py index 4b8d731..e000d63 100644 --- a/wizard/parsers/parser_gps.py +++ b/wizard/parsers/parser_gps.py @@ -182,6 +182,7 @@ class GPSCatTrackParser(CSVParser): ''' DATATYPE = "gps_cattrack" DIVIDER = "--------\n" + START_WITH = "Name:CatLog" FIELDS = [ "Date", "Time", "Latitude", "Longitude", "Altitude", "Satellites", "HDOP", "PDOP", "Temperature [C]", "Speed [km/h]", "TTFF", "SNR", "tbd"] @@ -213,11 +214,14 @@ def __init__(self, stream): if not self.stream.seekable(): self._raise_not_supported('Stream not seekable') - if not stream_starts_with(self.stream, "Name:CatLog"): + if self.START_WITH and not stream_starts_with(self.stream, self.START_WITH): self._raise_not_supported(f"Stream must start with Name:CatLog") - _intro, data = self.stream.read().split(self.DIVIDER) - content = io.StringIO(data) + if self.DIVIDER: + _intro, data = self.stream.read().split(self.DIVIDER) + content = io.StringIO(data) + else: + content = self.stream reader = csv.reader(content, delimiter=self.SEPARATOR, skipinitialspace=self.SKIP_INITIAL_SPACE) header = next(reader) @@ -227,6 +231,34 @@ def __init__(self, stream): self.data = pd.read_csv(content, header=0, names=self.FIELDS, sep=self.SEPARATOR, index_col=False) +class GPSCatTrackNoDivider(GPSCatTrackParser): + DIVIDER = None + START_WITH = None + FIELDS = [ +"Date", "Time", "Latitude", "Longitude", "Altitude", "Satellites", "HDOP", "PDOP"] + + MAPPINGS = { + "id": "", + "date": "Date", + "time": "Time", + "latitude": "Latitude", + "longitude": "Longitude", + "altitude": "Altitude", + "speed_km_h": None, + "type": None, + "distance": None, + "course": None, + "hdop": "HDOP", + "pdop": "PDOP", + "satellites_count": "Satellites", + "temperature": None, + "solar_I_mA": None, + "bat_soc_pct": None, + "ring_nr": None, + "trip_nr": None, + } + + class GPS2JMParser(CSVParser): ''' Parser for 2Jm format @@ -300,4 +332,5 @@ def __init__(self, stream): IGotU_GT_Parser, IGotU_GT_TabSeparatedParser, GPS2JMParser, + GPSCatTrackNoDivider, ] \ No newline at end of file diff --git a/wizard/parsers/tests/parser_test.py b/wizard/parsers/tests/parser_test.py index fb086b1..0cfe8c9 100644 --- a/wizard/parsers/tests/parser_test.py +++ b/wizard/parsers/tests/parser_test.py @@ -9,10 +9,16 @@ IGNORED_FILES = [ '.gitkeep', ] +IGNORED_DIRS = [ + # 'gps_gpx', + # 'accelerometer', + # 'gps_pathtrack', + # 'tdr', +] testdata_success = [] for dir in (TESTS_DATA_PATH / 'success').iterdir(): - if dir.is_dir() and not dir.name.endswith('__ignore'): + if dir.is_dir() and dir.name not in IGNORED_DIRS: for f in dir.iterdir(): if not f.is_dir() and f.name not in IGNORED_FILES: testdata_success.append((f.name, f, dir.name))