Fix order in which grids are parsed out of comments

This commit is contained in:
Ian Renton
2026-09-20 19:01:48 +01:00
parent 6f96e0ede1
commit 9272766ffb
9 changed files with 34 additions and 34 deletions
+19 -19
View File
@@ -380,11 +380,19 @@ class Spot:
self.propagation_mode = mode_tag
logger.info(f"Seen a new propagation mode tag not yet in the system: {mode_tag}")
# Set activities based on propagation mode
if self.propagation_mode == "Satellite" and not self.sig:
self.sig = ActivityName.SATELLITE
if self.propagation_mode == "Earth-Moon-Earth" and not self.sig:
self.sig = ActivityName.EME
# Parse "de_grid -> dx_grid" structures from the comment
if self.comment:
grid_match = re.search(
r"\b([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\s*->\s*([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\b",
self.comment,
)
if grid_match:
# regex matches, so extract grids:
if not self.de_grid:
self.de_grid = grid_match.group(1).upper()
if not self.dx_grid:
self.dx_grid = grid_match.group(2).upper()
self.dx_location_source = LocationSourceForSpot.GRID
# Parse 6-digit grid structures from the comment if the frequency is VHF or above, as it's common to see
# VHF+ operators spotted with their grid
@@ -397,6 +405,12 @@ class Spot:
self.dx_grid = grid_match.group(1).upper()
self.dx_location_source = LocationSourceForSpot.GRID
# Set activities based on propagation mode
if self.propagation_mode == "Satellite" and not self.sig:
self.sig = ActivityName.SATELLITE
if self.propagation_mode == "Earth-Moon-Earth" and not self.sig:
self.sig = ActivityName.EME
# Set activities based on the DX callsign suffix
if self.dx_call and not self.sig:
if self.dx_call.upper().endswith(ActivityName.AERONAUTICAL_MOBILE):
@@ -420,20 +434,6 @@ class Spot:
self.sig = ActivityName.DXPEDITION
break
# Parse "de_grid -> dx_grid" structures from the comment
if self.comment:
grid_match = re.search(
r"\b([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\s*->\s*([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\b",
self.comment,
)
if grid_match:
# regex matches, so extract grids:
if not self.dx_grid:
self.dx_grid = grid_match.group(1).upper()
self.dx_location_source = LocationSourceForSpot.GRID
if not self.de_grid:
self.de_grid = grid_match.group(2).upper()
# DX Grid to lat/lon and vice versa in case one is missing
if self.dx_grid and (not self.dx_latitude or not self.dx_longitude):
try: