mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
Fix a bug in PNP spot handling where an exception would be thrown if an activity had a location name but not a reference ID.
This commit is contained in:
@@ -68,21 +68,33 @@ class ParksNPeaks(HTTPSpotProvider):
|
||||
# Record activity information
|
||||
activity = source_spot["actClass"].upper()
|
||||
ref_id = source_spot["actSiteID"]
|
||||
|
||||
if activity:
|
||||
spot.sig = activity
|
||||
activity_refs = []
|
||||
|
||||
if ref_id:
|
||||
activity_refs = [
|
||||
ActivityRef(
|
||||
id=source_spot["actSiteID"],
|
||||
id=ref_id,
|
||||
sig=activity,
|
||||
# Free text location is not present in all spots, so only add it if it's set
|
||||
name=source_spot["actLocation"]
|
||||
if "actLocation" in source_spot and source_spot["actLocation"] != ""
|
||||
else None,
|
||||
)
|
||||
]
|
||||
spot.sig_refs = activity_refs
|
||||
|
||||
# Free text location is not present in all spots, so only add it if it's set
|
||||
if "actLocation" in source_spot and source_spot["actLocation"] != "":
|
||||
activity_refs[0].name = source_spot["actLocation"]
|
||||
else:
|
||||
# If no actSiteID is set, e.g. because actClass is "QRP", sometimes we still have an actLocation
|
||||
# which is free text like "SOTA G/SC-001". If we have that, and not a normal comment field, use
|
||||
# that location as the comment field so the information doesn't get lost.
|
||||
if (
|
||||
"actLocation" in source_spot
|
||||
and source_spot["actLocation"] != ""
|
||||
and ("actComments" not in source_spot or source_spot["actComments"] == "")
|
||||
):
|
||||
spot.comment = source_spot["actLocation"]
|
||||
|
||||
# Log a warning for the developer if PnP gives us an unknown programme we've never seen before
|
||||
if activity not in [
|
||||
@@ -95,8 +107,11 @@ class ParksNPeaks(HTTPSpotProvider):
|
||||
ActivityName.KRMNPA,
|
||||
ActivityName.SANPCPA,
|
||||
ActivityName.LLOTA,
|
||||
ActivityName.QRP,
|
||||
]:
|
||||
logger.warning(f"PNP spot found with activity {activity}, developer needs to add support for this!")
|
||||
logger.warning(
|
||||
f"PNP spot found with activity {activity}, developer needs to add support for this!"
|
||||
)
|
||||
|
||||
# Add new spot to the list
|
||||
new_spots.append(spot)
|
||||
|
||||
Reference in New Issue
Block a user