Allow standard parentheses for DX cluster "de_grid<prop_mode>dx_grid" structures

This commit is contained in:
Ian Renton
2026-06-21 22:18:20 +01:00
parent 615e1183a8
commit f28bcc2464
9 changed files with 21 additions and 21 deletions

View File

@@ -290,23 +290,23 @@ class Spot:
if self.sig_refs and len(self.sig_refs) > 0 and not self.sig:
self.sig = self.sig_refs[0].sig
# Parse "de_grid<prop_mode>dx_grid" structures from the comment, e.g. "JN61ES<ES>JM56XT" or "JO02GQ<>KN17LG".
# Parse "de_grid<prop_mode>dx_grid" structures from the comment, e.g. "JN61ES(ES)JM56XT" or "JO02GQ<>KN17LG".
# These are common on cluster spots and can provide grid references in preference to e.g. QRZ lookup, as well as
# being the only source we have for propagation mode.
# being the only source we have for propagation mode. Brace for nightmare regex from hell.
if self.comment:
grid_mode_grid_match = re.search(
r'\b([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)<([^>]*)>([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\b',
r'\b([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)(?:<([^>]*)>|\(([^)]*)\))([A-Ra-r]{2}\d{2}(?:[A-Xa-x]{2}(?:\d{2})?)?)\b',
self.comment)
if grid_mode_grid_match:
# regex matches, so extract grids:
if not self.de_grid:
self.de_grid = grid_mode_grid_match.group(1).upper()
if not self.dx_grid:
self.dx_grid = grid_mode_grid_match.group(3).upper()
self.dx_grid = grid_mode_grid_match.group(4).upper()
self.dx_location_source = "SPOT"
# And extract propagation mode:
mode_tag = grid_mode_grid_match.group(2).upper()
# And extract propagation mode (group 2 for <...>, group 3 for (...)):
mode_tag = (grid_mode_grid_match.group(2) or grid_mode_grid_match.group(3) or "").upper()
if mode_tag and not self.propagation_mode:
if mode_tag in PROPAGATION_MODES:
self.propagation_mode = PROPAGATION_MODES[mode_tag]