When checking comments for activity names and ref regexes, stop consuming the non-word characters each side of the match. This was causing multiple references next to each other in a list to skip every even numbered reference.

This commit is contained in:
Ian Renton
2026-09-25 07:54:43 +01:00
parent e2267ba27f
commit 7417140a3d
9 changed files with 23 additions and 23 deletions
+8 -8
View File
@@ -283,21 +283,21 @@ class Spot:
activity = self.activity_refs[0].activity.upper()
regex = get_ref_regex_for_activity(activity)
if regex:
all_comment_ref_matches = re.finditer(r"(^|\W)(" + regex + r")($|\W)", self.comment, re.IGNORECASE)
all_comment_ref_matches = re.finditer(r"(?<!\w)(" + regex + r")(?!\w)", self.comment, re.IGNORECASE)
for ref_match in all_comment_ref_matches:
self._append_activity_ref_if_missing(
ActivityRef(id=ref_match.group(2).upper(), activity=activity)
ActivityRef(id=ref_match.group(1).upper(), activity=activity)
)
# See if the comment looks like it contains any activities (and optionally activity references) that we
# can add to the spot. This should catch cluster spot comments like "POTA GB-0001 WWFF GFF-0001" and e.g.
# POTA comments like "also WWFF GFF-0001".
if self.comment:
activity_matches = re.finditer(r"(^|\W)" + ANY_ACTIVITY_REGEX + r"($|\W)", self.comment, re.IGNORECASE)
activity_matches = re.finditer(r"(?<!\w)" + ANY_ACTIVITY_REGEX + r"(?!\w)", self.comment, re.IGNORECASE)
for activity_match in activity_matches:
# First of all, add the activity to this spot's list of activities. This covers
# things like cluster spots where the comment is just "POTA".
found_activity = get_activity_name_from_comment_name(activity_match.group(2))
found_activity = get_activity_name_from_comment_name(activity_match.group(1))
self.add_activity(found_activity)
# Now look to see if that activity name was followed by something that looks like a reference ID
@@ -305,13 +305,13 @@ class Spot:
found_activity_info = get_activity_by_name(found_activity)
if found_activity_info and found_activity_info.has_refs and found_activity_info.ref_regex:
ref_matches = re.finditer(
r"(^|\W)" + found_activity + r"([ -])(" + found_activity_info.ref_regex + r")($|\W)",
r"(?<!\w)" + found_activity + r"[ -](" + found_activity_info.ref_regex + r")(?!\w)",
self.comment,
re.IGNORECASE,
)
for ref_match in ref_matches:
self._append_activity_ref_if_missing(
ActivityRef(id=ref_match.group(3).upper(), activity=found_activity)
ActivityRef(id=ref_match.group(1).upper(), activity=found_activity)
)
# See if the comment looks like it contains any activity references *without* the corresponding activity
@@ -321,14 +321,14 @@ class Spot:
for activity in ACTIVITIES.values():
if activity.has_refs and activity.refs_globally_unique and activity.ref_regex:
ref_matches = re.finditer(
r"(^|\W)(" + activity.ref_regex + r")($|\W)", self.comment, re.IGNORECASE
r"(?<!\w)(" + activity.ref_regex + r")(?!\w)", self.comment, re.IGNORECASE
)
for ref_match in ref_matches:
# First of all, add the activity to this spot's list of activities. This covers things
# like cluster spots where the comment is just "OHFF-1234", now we know it's WWFF.
self.add_activity(activity.name)
self._append_activity_ref_if_missing(
ActivityRef(id=ref_match.group(2).upper(), activity=activity.name)
ActivityRef(id=ref_match.group(1).upper(), activity=activity.name)
)
# Fetch activity data. In case a particular API doesn't provide a full set of name, lat, lon & grid for a
+1 -1
View File
@@ -77,7 +77,7 @@
</div>
<script src="/static/js/add-spot.js?v=1790316650"></script>
<script src="/static/js/add-spot.js?v=1790319283"></script>
<script>$(document).ready(function () {
$("#nav-link-add-spot").addClass("active");
}); <!-- highlight active page in nav --></script>
+1 -1
View File
@@ -85,7 +85,7 @@
</div>
<script src="/static/js/alerts.js?v=1790316650"></script>
<script src="/static/js/alerts.js?v=1790319283"></script>
<script>$(document).ready(function () {
$("#nav-link-alerts").addClass("active");
}); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -76,8 +76,8 @@
</div>
<script src="/static/js/spotsbandsandmap.js?v=1790316650"></script>
<script src="/static/js/bands.js?v=1790316650"></script>
<script src="/static/js/spotsbandsandmap.js?v=1790319283"></script>
<script src="/static/js/bands.js?v=1790319283"></script>
<script>$(document).ready(function () {
$("#nav-link-bands").addClass("active");
}); <!-- highlight active page in nav --></script>
+5 -5
View File
@@ -1,6 +1,6 @@
{% extends "skeleton.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/css/style.css?v=1790316650" type="text/css">
<link rel="stylesheet" href="/static/css/style.css?v=1790319283" type="text/css">
<link href="/static/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet">
<link href="/static/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet">
<link href="/static/vendor/css/solid-6.7.2.min.css" rel="stylesheet">
@@ -16,10 +16,10 @@
window.fetchEventSource = fetchEventSource;
</script>
<script src="/static/js/utils.js?v=1790316650"></script>
<script src="/static/js/ui-ham.js?v=1790316650"></script>
<script src="/static/js/geo.js?v=1790316650"></script>
<script src="/static/js/common.js?v=1790316650"></script>
<script src="/static/js/utils.js?v=1790319283"></script>
<script src="/static/js/ui-ham.js?v=1790319283"></script>
<script src="/static/js/geo.js?v=1790319283"></script>
<script src="/static/js/common.js?v=1790319283"></script>
{% end %}
{% block body %}
<div class="container">
+1 -1
View File
@@ -284,7 +284,7 @@
</div>
<script src="/static/vendor/js/chart-4.4.9.umd.min.js"></script>
<script src="/static/js/conditions.js?v=1790316650"></script>
<script src="/static/js/conditions.js?v=1790319283"></script>
<script>$(document).ready(function () {
$("#nav-link-conditions").addClass("active");
}); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -113,8 +113,8 @@
const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}";
</script>
<script src="/static/js/spotsbandsandmap.js?v=1790316650"></script>
<script src="/static/js/map.js?v=1790316650"></script>
<script src="/static/js/spotsbandsandmap.js?v=1790319283"></script>
<script src="/static/js/map.js?v=1790319283"></script>
<script>$(document).ready(function () {
$("#nav-link-map").addClass("active");
}); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -125,8 +125,8 @@
</div>
<script src="/static/js/spotsbandsandmap.js?v=1790316650"></script>
<script src="/static/js/spots.js?v=1790316650"></script>
<script src="/static/js/spotsbandsandmap.js?v=1790319283"></script>
<script src="/static/js/spots.js?v=1790319283"></script>
<script>$(document).ready(function () {
$("#nav-link-spots").addClass("active");
}); <!-- highlight active page in nav --></script>
+1 -1
View File
@@ -96,7 +96,7 @@
</div>
</div>
<script src="/static/js/status.js?v=1790316650"></script>
<script src="/static/js/status.js?v=1790319283"></script>
<script>
$(document).ready(function () {
$("#nav-link-status").addClass("active");