More ruff linter fixes

This commit is contained in:
Ian Renton
2026-08-15 08:43:19 +01:00
parent dd89ff4af7
commit a6e54f524d
43 changed files with 99 additions and 153 deletions
+4 -4
View File
@@ -139,10 +139,10 @@ class HamQTH(APIQueryCallsignDataProvider):
return Callsign(
call=callsign,
home_call=callinfo.Callinfo.get_homecall(callsign),
name=data["nick"] if "nick" in data else None,
qth=data["qth"] if "qth" in data else None,
country=data["country"] if "country" in data else None,
continent=data["continent"] if "continent" in data else None,
name=data.get("nick", None),
qth=data.get("qth", None),
country=data.get("country", None),
continent=data.get("continent", None),
latitude=lat,
longitude=lon,
grid=grid,
+3 -3
View File
@@ -161,9 +161,9 @@ class QRZ(APIQueryCallsignDataProvider):
call=callsign,
home_call=callinfo.Callinfo.get_homecall(callsign),
name=name,
qth=data["addr2"] if "addr2" in data else None,
country=data["country"] if "country" in data else None,
continent=data["continent"] if "continent" in data else None,
qth=data.get("addr2", None),
country=data.get("country", None),
continent=data.get("continent", None),
latitude=lat,
longitude=lon,
grid=grid,
+1 -1
View File
@@ -26,7 +26,7 @@ class ARLHS(FileDownloadSIGRefDataProvider):
SIGRef(
sig=self.SIG,
id=ref_id,
name=row["Name"] if "Name" in row else None,
name=row.get("Name", None),
ref_type="Lighthouse",
url=f"https://www.cqgma.org/zinfo.php?ref={ref_id}",
latitude=float(row["Latitude"]) if "Latitude" in row and row["Latitude"] != "" else None,
+1 -1
View File
@@ -25,7 +25,7 @@ class GMA(FileDownloadSIGRefDataProvider):
SIGRef(
sig=self.SIG,
id=ref_id,
name=row["Name"] if "Name" in row else None,
name=row.get("Name", None),
ref_type="Summit",
url=f"https://www.cqgma.org/zinfo.php?ref={ref_id}",
latitude=float(row["Latitude"]) if "Latitude" in row and row["Latitude"] != "" else None,
+1 -1
View File
@@ -26,7 +26,7 @@ class ILLW(FileDownloadSIGRefDataProvider):
SIGRef(
sig=self.SIG,
id=ref_id,
name=row["Name"] if "Name" in row else None,
name=row.get("Name", None),
ref_type="Lighthouse",
url=f"https://www.cqgma.org/zinfo.php?ref={ref_id}",
latitude=float(row["Latitude"]) if "Latitude" in row and row["Latitude"] != "" else None,
+1 -1
View File
@@ -25,7 +25,7 @@ class MOTA(FileDownloadSIGRefDataProvider):
SIGRef(
sig=self.SIG,
id=ref_id,
name=row["Name"] if "Name" in row else None,
name=row.get("Name", None),
ref_type="Mill",
url=f"https://www.cqgma.org/zinfo.php?ref={ref_id}",
latitude=float(row["Latitude"]) if "Latitude" in row and row["Latitude"] != "" else None,
+2 -2
View File
@@ -25,10 +25,10 @@ class POTA(FileDownloadSIGRefDataProvider):
SIGRef(
sig=self.SIG,
id=ref_id,
name=row["name"] if "name" in row else None,
name=row.get("name", None),
ref_type="Park",
url=f"https://pota.app/#/park/{ref_id}",
grid=row["grid"] if "grid" in row else None,
grid=row.get("grid", None),
latitude=float(row["latitude"]) if "latitude" in row and row["latitude"] != "" else None,
longitude=float(row["longitude"]) if "longitude" in row and row["longitude"] != "" else None,
)
+2 -2
View File
@@ -25,9 +25,9 @@ class SIOTA(FileDownloadSIGRefDataProvider):
SIGRef(
sig=self.SIG,
id=ref_id,
name=row["NAME"] if "NAME" in row else None,
name=row.get("NAME", None),
ref_type="Silo",
grid=row["LOCATOR"] if "LOCATOR" in row else None,
grid=row.get("LOCATOR", None),
latitude=float(row["LAT"]) if "LAT" in row else None,
longitude=float(row["LNG"]) if "LNG" in row else None,
)
+1 -1
View File
@@ -29,7 +29,7 @@ class SOTA(FileDownloadSIGRefDataProvider):
ref = SIGRef(
sig=self.SIG,
id=ref_id,
name=row["SummitName"] if "SummitName" in row else None,
name=row.get("SummitName", None),
ref_type="Summit",
url=f"https://www.sotadata.org.uk/en/summit/{ref_id}",
latitude=latitude,
+1 -1
View File
@@ -25,7 +25,7 @@ class Towers(FileDownloadSIGRefDataProvider):
SIGRef(
sig=self.SIG,
id=ref_id,
name=row["Nazev"] if "Nazev" in row else None,
name=row.get("Nazev", None),
ref_type="Tower",
url=f"https://wwtota.com/seznam/karta_rozhledny.php?ref={ref_id}",
grid=row["Lokator"] if "Lokator" in row and row["Lokator"] != "" else None,
+1 -1
View File
@@ -44,7 +44,7 @@ class WCA(FileDownloadSIGRefDataProvider):
SIGRef(
sig=self.SIG,
id=ref_id,
name=row["CLEAN NAME"] if "CLEAN NAME" in row else None,
name=row.get("CLEAN NAME", None),
ref_type="Castle",
url=f"https://www.cqgma.org/zinfo.php?ref={ref_id}",
latitude=latitude,
+1 -1
View File
@@ -25,7 +25,7 @@ class WWBOTA(FileDownloadSIGRefDataProvider):
SIGRef(
sig=self.SIG,
id=ref_id,
name=row["Name"] if "Name" in row else None,
name=row.get("Name", None),
ref_type="Bunker",
url=f"https://bunkerwiki.org/?s={ref_id}" if ref_id.startswith("B/G") else None,
grid=row["Locator"] if "Locator" in row and row["Locator"] != "" else None,
+1 -1
View File
@@ -25,7 +25,7 @@ class WWFF(FileDownloadSIGRefDataProvider):
SIGRef(
sig=self.SIG,
id=ref_id,
name=row["name"] if "name" in row else None,
name=row.get("name", None),
ref_type="Park",
url=f"https://wwff.co/directory/?showRef={ref_id}",
grid=row["iaruLocator"] if "iaruLocator" in row and row["iaruLocator"] != "-" else None,
+4 -4
View File
@@ -30,15 +30,15 @@ class DXCluster(SpotProvider):
def __init__(self, provider_config):
"""Constructor requires hostname and port"""
name = provider_config["name"] if "name" in provider_config else "Cluster"
name = provider_config.get("name", "Cluster")
super().__init__(name, provider_config)
self._hostname = provider_config["host"]
self._port = provider_config["port"]
self._login_prompt = provider_config["login_prompt"] if "login_prompt" in provider_config else "login:"
self._login_prompt = provider_config.get("login_prompt", "login:")
self._login_callsign = (
provider_config["login_callsign"] if "login_callsign" in provider_config else SERVER_OWNER_CALLSIGN
provider_config.get("login_callsign", SERVER_OWNER_CALLSIGN)
)
self._allow_rbn_spots = provider_config["allow_rbn_spots"] if "allow_rbn_spots" in provider_config else False
self._allow_rbn_spots = provider_config.get("allow_rbn_spots", False)
self._spot_line_pattern = (
self._LINE_PATTERN_ALLOW_RBN if self._allow_rbn_spots else self._LINE_PATTERN_EXCLUDE_RBN
)
+1 -1
View File
@@ -148,7 +148,7 @@ class GMA(HTTPSpotProvider):
logger.warning(
f"GMA API returned a malformed response when looking up ref {source_spot['REF']}"
)
except:
except Exception:
logger.exception(
f"Exception when looking up {self.REF_INFO_URL_ROOT}{source_spot['REF']}, ignoring this spot for now"
)
+1 -1
View File
@@ -26,7 +26,7 @@ class RBN(SpotProvider):
def __init__(self, provider_config):
"""Constructor requires port number."""
name = provider_config["name"] if "name" in provider_config else "RBN"
name = provider_config.get("name", "RBN")
super().__init__(name, provider_config)
self._port = provider_config["port"]
self._telnet = None
+1 -1
View File
@@ -39,7 +39,7 @@ class SpotProvider:
spot.infer_missing()
self._add_spot(spot)
if spots:
self.last_spot_time = datetime.fromtimestamp(max(map(lambda s: s.time, spots)), pytz.UTC)
self.last_spot_time = datetime.fromtimestamp(max(s.time for s in spots), pytz.UTC)
def _submit(self, spot):
"""Submit a single spot retrieved from the provider. This will be added to the list regardless of its age. Spots
+4 -4
View File
@@ -20,7 +20,7 @@ class UKPacketNet(HTTPSpotProvider):
new_spots = []
# Iterate through source data
nodes = http_response.json()["nodes"]
for callsign, node in nodes.items():
for node in nodes.values():
# The node corresponse to the spotter here. It has an "mheard" section which indicates which nodes it has
# recently heard, which will be our "DX". But "mheard" stations are not necessarily over RF, they could be
# via the internet, so we also need to look up the "port" on which the station was heard, and check that it
@@ -34,7 +34,7 @@ class UKPacketNet(HTTPSpotProvider):
# This is another packet station heard over RF, so we are good to create a Spot object.
# First build a "full" comment combining some of the extra info
comment = listed_port["comment"] if "comment" in listed_port else ""
comment = listed_port.get("comment", "")
comment = f"{comment} {listed_port['mode']}" if "mode" in listed_port else comment
comment = (
f"{comment} {listed_port['modulation']}" if "modulation" in listed_port else comment
@@ -82,7 +82,7 @@ class UKPacketNet(HTTPSpotProvider):
time=datetime.strptime(heard["lastHeard"], "%Y-%m-%d %H:%M:%S")
.replace(tzinfo=pytz.UTC)
.timestamp(),
de_grid=node["location"]["locator"] if "locator" in node["location"] else None,
de_grid=node["location"].get("locator", None),
de_latitude=node["location"]["coords"]["lat"],
de_longitude=node["location"]["coords"]["lon"],
)
@@ -99,7 +99,7 @@ class UKPacketNet(HTTPSpotProvider):
for spot in new_spots:
if spot.dx_call in nodes:
spot.dx_grid = (
nodes[spot.dx_call]["location"]["locator"] if "locator" in nodes[spot.dx_call]["location"] else None
nodes[spot.dx_call]["location"].get("locator", None)
)
spot.dx_latitude = nodes[spot.dx_call]["location"]["coords"]["lat"]
spot.dx_longitude = nodes[spot.dx_call]["location"]["coords"]["lon"]
+2 -2
View File
@@ -64,9 +64,9 @@ class WebsocketSpotProvider(SpotProvider):
except Exception:
logger.exception(f"Exception processing message from Websocket Spot Provider ({self.name})")
except Exception as e:
except Exception:
self.status = "Error"
logger.exception(f"Exception in Websocket Spot Provider ({self.name})", e)
logger.exception(f"Exception in Websocket Spot Provider ({self.name})")
else:
self.status = "Disconnected"
sleep(5) # Wait before trying to reconnect
+2 -3
View File
@@ -19,7 +19,6 @@ class WOTA(HTTPSpotProvider):
POLL_INTERVAL_SEC = 120
SPOTS_URL = "https://www.wota.org.uk/spots_rss.php"
LIST_URL = "https://www.wota.org.uk/mapping/data/summits.json"
RSS_DATE_TIME_FORMAT = "%a, %d %b %Y %H:%M:%S %z"
def __init__(self, provider_config):
@@ -83,8 +82,8 @@ class WOTA(HTTPSpotProvider):
)
new_spots.append(spot)
except Exception as e:
logger.error("Exception parsing WOTA spot", e)
except Exception:
logger.exception("Exception parsing WOTA spot")
return new_spots
def can_submit_spot(self, sig):
+1 -1
View File
@@ -20,7 +20,7 @@ class XOTA(WebsocketSpotProvider):
SIG = None
def __init__(self, provider_config):
name = provider_config["name"] if "name" in provider_config else "xOTA"
name = provider_config.get("name", "xOTA")
super().__init__(name, provider_config, provider_config["url"])
self.SIG = str(provider_config["sig"]) if "sig" in provider_config else None
self._sig_ref_prefix = str(provider_config["sig_ref_prefix"]) if "sig_ref_prefix" in provider_config else ""