mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-21 14:57:42 +00:00
Partial fix for mypy issues
This commit is contained in:
+13
-11
@@ -299,7 +299,7 @@ class Spot:
|
||||
# Now look to see if that activity name was followed by something that looks like a reference ID
|
||||
# for that activity. If so, add that to the sig_refs list for this 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:
|
||||
if found_activity and 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)",
|
||||
self.comment,
|
||||
@@ -314,19 +314,19 @@ class Spot:
|
||||
# name, but where the activity reference is unique-looking enough that we can't confuse it with any other
|
||||
# activity.
|
||||
if self.comment:
|
||||
for activity in ACTIVITIES.values():
|
||||
if activity.has_refs and activity.refs_globally_unique and activity.ref_regex:
|
||||
for candidate_activity in ACTIVITIES.values():
|
||||
if candidate_activity.has_refs and candidate_activity.refs_globally_unique and candidate_activity.ref_regex:
|
||||
ref_matches = re.finditer(
|
||||
r"(^|\W)(" + activity.ref_regex + r")($|\W)", self.comment, re.IGNORECASE
|
||||
r"(^|\W)(" + candidate_activity.ref_regex + r")($|\W)", self.comment, re.IGNORECASE
|
||||
)
|
||||
for ref_match in ref_matches:
|
||||
# First of all, if we haven't got an activity for this spot set yet, now we have. This
|
||||
# covers things like cluster spots where the comment is just "OHFF-1234", now we know
|
||||
# it's WWFF.
|
||||
if not self.sig:
|
||||
self.sig = activity.name
|
||||
self.sig = candidate_activity.name
|
||||
self._append_activity_ref_if_missing(
|
||||
ActivityRef(id=ref_match.group(2).upper(), sig=activity.name)
|
||||
ActivityRef(id=ref_match.group(2).upper(), sig=candidate_activity.name)
|
||||
)
|
||||
|
||||
# Fetch activity data. In case a particular API doesn't provide a full set of name, lat, lon & grid for a
|
||||
@@ -473,12 +473,14 @@ class Spot:
|
||||
self.dx_latitude = dx_call_info.latitude
|
||||
self.dx_longitude = dx_call_info.longitude
|
||||
self.dx_grid = dx_call_info.grid
|
||||
self.dx_location_source = dx_call_info.location_source
|
||||
self.dx_location_source = (
|
||||
LocationSourceForSpot(dx_call_info.location_source) if dx_call_info.location_source else None
|
||||
)
|
||||
|
||||
# Determine a "QTH" string. If we have an activity ref, pick the first one and turn it into a suitable
|
||||
# string, otherwise see what they have set on an online lookup service.
|
||||
if self.sig_refs:
|
||||
qth = self.sig_refs[0].id
|
||||
qth = self.sig_refs[0].id or ""
|
||||
if self.sig_refs[0].name:
|
||||
qth += f" {self.sig_refs[0].name}"
|
||||
self.dx_qth = qth
|
||||
@@ -499,8 +501,8 @@ class Spot:
|
||||
|
||||
# DXCC lookup from callsign if nothing else has provided it
|
||||
if self.dx_call and not self.dx_dxcc_id:
|
||||
for regex, entity_code in DATA_STORE.dxcc_lookup_by_call_regex:
|
||||
if regex.pattern and regex.match(self.dx_call):
|
||||
for dxcc_regex, entity_code in DATA_STORE.dxcc_lookup_by_call_regex:
|
||||
if dxcc_regex.pattern and dxcc_regex.match(self.dx_call):
|
||||
self.dx_dxcc_id = entity_code
|
||||
break
|
||||
if self.dx_dxcc_id and not self.dx_flag:
|
||||
@@ -547,7 +549,7 @@ class Spot:
|
||||
def _append_activity_ref_if_missing(self, new_activity_ref: ActivityRef) -> None:
|
||||
"""Append an activity ref to the list, so long as it's not already there."""
|
||||
|
||||
new_activity_ref.id = new_activity_ref.id.strip().upper()
|
||||
new_activity_ref.id = (new_activity_ref.id or "").strip().upper()
|
||||
new_activity_ref.sig = new_activity_ref.sig.strip().upper()
|
||||
if new_activity_ref.id == "":
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user