mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-25 08:44:33 +00:00
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:
+8
-8
@@ -283,21 +283,21 @@ class Spot:
|
|||||||
activity = self.activity_refs[0].activity.upper()
|
activity = self.activity_refs[0].activity.upper()
|
||||||
regex = get_ref_regex_for_activity(activity)
|
regex = get_ref_regex_for_activity(activity)
|
||||||
if regex:
|
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:
|
for ref_match in all_comment_ref_matches:
|
||||||
self._append_activity_ref_if_missing(
|
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
|
# 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.
|
# 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".
|
# POTA comments like "also WWFF GFF-0001".
|
||||||
if self.comment:
|
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:
|
for activity_match in activity_matches:
|
||||||
# First of all, add the activity to this spot's list of activities. This covers
|
# 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".
|
# 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)
|
self.add_activity(found_activity)
|
||||||
|
|
||||||
# Now look to see if that activity name was followed by something that looks like a reference ID
|
# 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)
|
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:
|
if found_activity_info and found_activity_info.has_refs and found_activity_info.ref_regex:
|
||||||
ref_matches = re.finditer(
|
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,
|
self.comment,
|
||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
)
|
)
|
||||||
for ref_match in ref_matches:
|
for ref_match in ref_matches:
|
||||||
self._append_activity_ref_if_missing(
|
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
|
# 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():
|
for activity in ACTIVITIES.values():
|
||||||
if activity.has_refs and activity.refs_globally_unique and activity.ref_regex:
|
if activity.has_refs and activity.refs_globally_unique and activity.ref_regex:
|
||||||
ref_matches = re.finditer(
|
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:
|
for ref_match in ref_matches:
|
||||||
# First of all, add the activity to this spot's list of activities. This covers things
|
# 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.
|
# like cluster spots where the comment is just "OHFF-1234", now we know it's WWFF.
|
||||||
self.add_activity(activity.name)
|
self.add_activity(activity.name)
|
||||||
self._append_activity_ref_if_missing(
|
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
|
# Fetch activity data. In case a particular API doesn't provide a full set of name, lat, lon & grid for a
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
|
|
||||||
</div>
|
</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 () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-add-spot").addClass("active");
|
$("#nav-link-add-spot").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/alerts.js?v=1790316650"></script>
|
<script src="/static/js/alerts.js?v=1790319283"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-alerts").addClass("active");
|
$("#nav-link-alerts").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -76,8 +76,8 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/spotsbandsandmap.js?v=1790316650"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1790319283"></script>
|
||||||
<script src="/static/js/bands.js?v=1790316650"></script>
|
<script src="/static/js/bands.js?v=1790319283"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-bands").addClass("active");
|
$("#nav-link-bands").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
{% extends "skeleton.html" %}
|
{% extends "skeleton.html" %}
|
||||||
{% block head_extra %}
|
{% 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/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/fontawesome-6.7.2.min.css" rel="stylesheet">
|
||||||
<link href="/static/vendor/css/solid-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;
|
window.fetchEventSource = fetchEventSource;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="/static/js/utils.js?v=1790316650"></script>
|
<script src="/static/js/utils.js?v=1790319283"></script>
|
||||||
<script src="/static/js/ui-ham.js?v=1790316650"></script>
|
<script src="/static/js/ui-ham.js?v=1790319283"></script>
|
||||||
<script src="/static/js/geo.js?v=1790316650"></script>
|
<script src="/static/js/geo.js?v=1790319283"></script>
|
||||||
<script src="/static/js/common.js?v=1790316650"></script>
|
<script src="/static/js/common.js?v=1790319283"></script>
|
||||||
{% end %}
|
{% end %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|||||||
@@ -284,7 +284,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/vendor/js/chart-4.4.9.umd.min.js"></script>
|
<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 () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-conditions").addClass("active");
|
$("#nav-link-conditions").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
+2
-2
@@ -113,8 +113,8 @@
|
|||||||
const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}";
|
const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="/static/js/spotsbandsandmap.js?v=1790316650"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1790319283"></script>
|
||||||
<script src="/static/js/map.js?v=1790316650"></script>
|
<script src="/static/js/map.js?v=1790319283"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-map").addClass("active");
|
$("#nav-link-map").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -125,8 +125,8 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/spotsbandsandmap.js?v=1790316650"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1790319283"></script>
|
||||||
<script src="/static/js/spots.js?v=1790316650"></script>
|
<script src="/static/js/spots.js?v=1790319283"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-spots").addClass("active");
|
$("#nav-link-spots").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/status.js?v=1790316650"></script>
|
<script src="/static/js/status.js?v=1790319283"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("#nav-link-status").addClass("active");
|
$("#nav-link-status").addClass("active");
|
||||||
|
|||||||
Reference in New Issue
Block a user