replace partition with split

partition is not available on all boards
This commit is contained in:
Jonas Kittner 2024-01-19 17:25:24 +01:00
parent f89329a981
commit 35f4904de3
2 changed files with 12 additions and 8 deletions

View file

@ -130,7 +130,11 @@ def _read_deg_mins(data: List[str], index: int, neg: str) -> Tuple[int, float]:
# longitudes, which makes parsing tricky:
# for latitudes: ddmm,mmmm (0 - 7 decimal places, not zero padded)
# for longitudes: dddmm,mmmm (0 - 7 decimal places, not zero padded)
int_part, _, minutes_decimal = data[index].partition(".")
if "." in data[index]:
int_part, minutes_decimal = data[index].split(".")
else:
int_part, minutes_decimal = data[index], 0
# we need to parse from right to left, minutes can only have 2 digits
minutes_int = int_part[-2:]
# the rest must be degrees which are either 2 or 3 digits

View file

@ -489,13 +489,13 @@ def test_GPS_update_from_GSV_both_parts_sats_are_removed():
@pytest.mark.parametrize(
("input_str", "exp", "neg"),
(
(["3723.2475", "N"], (37, 23.2475), "S"),
(["3723.2475", "S"], (-37, 23.2475), "s"),
(["00123.1234", "E"], (1, 23.1234), "W"),
(["00123", "E"], (1, 23), "W"),
(["1234.5678", "E"], (12, 34.5678), "W"),
(["3723.2475123", "N"], (37, 23.2475123), "S"),
(["3723", "N"], (37, 23), "S"),
(["3723.2475", "n"], (37, 23.2475), "s"),
(["3723.2475", "s"], (-37, 23.2475), "s"),
(["00123.1234", "e"], (1, 23.1234), "w"),
(["00123", "e"], (1, 23), "w"),
(["1234.5678", "e"], (12, 34.5678), "w"),
(["3723.2475123", "n"], (37, 23.2475123), "s"),
(["3723", "n"], (37, 23), "s"),
),
)
def test_read_min_secs(input_str, exp, neg):