flynt pass to provide consistency to string formatters and concatenation

This commit is contained in:
Ian Renton
2026-08-15 07:55:32 +01:00
parent bff5b79f8f
commit 7391c28cd0
72 changed files with 184 additions and 193 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ class ARLHS(FileDownloadSIGRefDataProvider):
ref_id = row["ARLHS"]
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Name"] if "Name" in row else None,
ref_type="Lighthouse",
url="https://www.cqgma.org/zinfo.php?ref=" + ref_id,
url=f"https://www.cqgma.org/zinfo.php?ref={ref_id}",
latitude=float(row["Latitude"]) if "Latitude" in row and row[
"Latitude"] != "" else None,
longitude=float(row["Longitude"]) if "Longitude" in row and row[
+1 -1
View File
@@ -28,7 +28,7 @@ class DME(LocalFileSIGRefDataProvider):
ref = SIGRef(sig=self.SIG, id=ref_id,
ref_type="Town",
name=row["NOMBRE_ACTUAL"] + ", " + row["PROVINCIA"],
name=f"{row['NOMBRE_ACTUAL']}, {row['PROVINCIA']}",
latitude=latitude,
longitude=longitude)
if latitude and longitude:
@@ -21,13 +21,13 @@ class FileDownloadSIGRefDataProvider(SIGRefDataProvider):
self._poll_interval = poll_interval
self._thread = None
self._stop_event = Event()
self._url_data_cache = URLDataCache("sigrefdata_" + sig_name)
self._url_data_cache = URLDataCache(f"sigrefdata_{sig_name}")
def start(self):
# Fire off the polling thread. It will poll immediately on startup, then sleep for poll_interval between
# subsequent polls, so start() returns immediately and the application can continue starting.
logging.info(
"Set up query of " + self.sig_name + " SIG ref data every " + str(self._poll_interval) + " days.")
f"Set up query of {self.sig_name} SIG ref data every {self._poll_interval!s} days.")
self._thread = Thread(target=self._run, name=f"FileDownloadSIGRefDataProvider-{self.sig_name}")
self._thread.start()
@@ -45,7 +45,7 @@ class FileDownloadSIGRefDataProvider(SIGRefDataProvider):
try:
# Request data from API. Use the data cache (with a TTL of 1 day) here, not as the main mechanism for
# caching, but just so continual restarts of the software during testing don't hammer the servers.
logging.debug("Downloading " + self.sig_name + " SIG ref data...")
logging.debug(f"Downloading {self.sig_name} SIG ref data...")
http_response = self._url_data_cache.get(self._url, headers=HTTP_HEADERS)
# Check response code was good
if http_response.ok:
@@ -57,7 +57,7 @@ class FileDownloadSIGRefDataProvider(SIGRefDataProvider):
self.status = "OK"
self.last_update_time = datetime.now(pytz.UTC)
logging.debug("Received SIG ref data for " + self.sig_name)
logging.debug(f"Received SIG ref data for {self.sig_name}")
else:
self.status = "Error"
logging.warning(f"HTTP {http_response.status_code} when downloading SIG ref data for {self.sig_name}.")
@@ -70,7 +70,7 @@ class FileDownloadSIGRefDataProvider(SIGRefDataProvider):
logging.warning(f"Timeout when downloading SIG ref data for {self.sig_name}.")
except Exception:
self.status = "Error"
logging.exception("Exception in HTTP SIG Ref Data Provider (" + self.sig_name + ")")
logging.exception(f"Exception in HTTP SIG Ref Data Provider ({self.sig_name})")
self._stop_event.wait(timeout=1)
def _http_response_to_data(self, http_response):
+1 -1
View File
@@ -21,7 +21,7 @@ class GMA(FileDownloadSIGRefDataProvider):
ref_id = row["Reference"]
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Name"] if "Name" in row else None,
ref_type="Summit",
url="https://www.cqgma.org/zinfo.php?ref=" + ref_id,
url=f"https://www.cqgma.org/zinfo.php?ref={ref_id}",
latitude=float(row["Latitude"]) if "Latitude" in row and row[
"Latitude"] != "" else None,
longitude=float(row["Longitude"]) if "Longitude" in row and row[
+1 -1
View File
@@ -22,7 +22,7 @@ class ILLW(FileDownloadSIGRefDataProvider):
ref_id = row["ILLW"]
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Name"] if "Name" in row else None,
ref_type="Lighthouse",
url="https://www.cqgma.org/zinfo.php?ref=" + ref_id,
url=f"https://www.cqgma.org/zinfo.php?ref={ref_id}",
latitude=float(row["Latitude"]) if "Latitude" in row and row[
"Latitude"] != "" else None,
longitude=float(row["Longitude"]) if "Longitude" in row and row[
+1 -1
View File
@@ -27,7 +27,7 @@ class LLOTA(FileDownloadSIGRefDataProvider):
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=str(ref["name"]),
ref_type="Lake",
url="https://llota.app/list/ref/" + ref_id,
url=f"https://llota.app/list/ref/{ref_id}",
grid=grid,
latitude=ll[0],
longitude=ll[1]))
@@ -14,7 +14,7 @@ class LocalFileSIGRefDataProvider(SIGRefDataProvider):
self._path = path
def start(self):
logging.debug("Loading " + self.sig_name + " SIG ref data from file.")
logging.debug(f"Loading {self.sig_name} SIG ref data from file.")
try:
new_data = self._file_to_data(self._path)
if new_data:
@@ -23,10 +23,10 @@ class LocalFileSIGRefDataProvider(SIGRefDataProvider):
self.last_update_time = datetime.now(pytz.UTC)
else:
self.status = "Error"
logging.info("Failed to load SIG ref data for " + self.sig_name)
logging.info(f"Failed to load SIG ref data for {self.sig_name}")
except Exception:
self.status = "Error"
logging.exception("Exception in local file SIG Ref Data Provider (" + self.sig_name + ")")
logging.exception(f"Exception in local file SIG Ref Data Provider ({self.sig_name})")
def _file_to_data(self, path):
"""Load a file on the given path and turn it into SIG Ref data."""
+1 -1
View File
@@ -21,7 +21,7 @@ class MOTA(FileDownloadSIGRefDataProvider):
ref_id = row["Reference"]
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Name"] if "Name" in row else None,
ref_type="Mill",
url="https://www.cqgma.org/zinfo.php?ref=" + ref_id,
url=f"https://www.cqgma.org/zinfo.php?ref={ref_id}",
latitude=float(row["Latitude"]) if "Latitude" in row and row[
"Latitude"] != "" else None,
longitude=float(row["Longitude"]) if "Longitude" in row and row[
@@ -39,7 +39,7 @@ class ParksNPeaksKMLSIGRefDataProvider(FileDownloadSIGRefDataProvider):
ref = SIGRef(sig=self.sig_name, id=ref_id, name=placemark.name,
ref_type="Park",
url="https://parksnpeaks.org/getPark.php?actPark=" + ref_id,
url=f"https://parksnpeaks.org/getPark.php?actPark={ref_id}",
latitude=latitude,
longitude=longitude)
if latitude and longitude:
+1 -1
View File
@@ -21,7 +21,7 @@ class POTA(FileDownloadSIGRefDataProvider):
ref_id = row["reference"]
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["name"] if "name" in row else None,
ref_type="Park",
url="https://pota.app/#/park/" + ref_id,
url=f"https://pota.app/#/park/{ref_id}",
grid=row["grid"] if "grid" in row else None,
latitude=float(row["latitude"]) if "latitude" in row and row[
"latitude"] != "" else None,
@@ -38,7 +38,7 @@ class SIGRefDataProvider:
# with transact() batches all writes together to save making thousands of individual sqlite writes
with DATA_STORE.sigrefs.transact():
for d in new_data:
DATA_STORE.sigrefs.set(self.sig_name + ":" + d.id, d)
DATA_STORE.sigrefs.set(f"{self.sig_name}:{d.id}", d)
# For the big data sources, loading will take a few minutes. If we want to shut down the software neatly
# within the first few minutes of startup, we need a way to abort this expensive process of filling up the
+1 -1
View File
@@ -26,7 +26,7 @@ class SOTA(FileDownloadSIGRefDataProvider):
altitude = float(row["AltM"]) if "AltM" in row and row["AltM"] != "" else None
ref = SIGRef(sig=self.SIG, id=ref_id, name=row["SummitName"] if "SummitName" in row else None,
ref_type="Summit",
url="https://www.sotadata.org.uk/en/summit/" + ref_id,
url=f"https://www.sotadata.org.uk/en/summit/{ref_id}",
latitude=latitude,
longitude=longitude,
altitude=altitude,
+1 -1
View File
@@ -21,7 +21,7 @@ class Towers(FileDownloadSIGRefDataProvider):
ref_id = row["Ref"]
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Nazev"] if "Nazev" in row else None,
ref_type="Tower",
url="https://wwtota.com/seznam/karta_rozhledny.php?ref=" + ref_id,
url=f"https://wwtota.com/seznam/karta_rozhledny.php?ref={ref_id}",
grid=row["Lokator"] if "Lokator" in row and row["Lokator"] != "" else None,
latitude=float(row["Lat"]) if "Lat" in row and row["Lat"] != "" else None,
longitude=float(row["Lon"]) if "Lon" in row and row["Lon"] != "" else None))
+1 -1
View File
@@ -38,7 +38,7 @@ class WCA(FileDownloadSIGRefDataProvider):
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["CLEAN NAME"] if "CLEAN NAME" in row else None,
ref_type="Castle",
url="https://www.cqgma.org/zinfo.php?ref=" + ref_id,
url=f"https://www.cqgma.org/zinfo.php?ref={ref_id}",
latitude=latitude,
longitude=longitude,
grid=grid))
+2 -2
View File
@@ -20,10 +20,10 @@ class WOTA(FileDownloadSIGRefDataProvider):
ref_id = feature["properties"]["wotaId"]
# Fudge WOTA URLs. Outlying fell (LDO) URLs don't match their ID numbers but require 214 to be
# added to them
url = "https://www.wota.org.uk/MM_" + ref_id
url = f"https://www.wota.org.uk/MM_{ref_id}"
if ref_id.upper().startswith("LDO-"):
number = int(ref_id.upper().replace("LDO-", ""))
url = "https://www.wota.org.uk/MM_LDO-" + str(number + 214)
url = f"https://www.wota.org.uk/MM_LDO-{number + 214!s}"
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=feature["properties"]["title"], url=url,
ref_type="Summit",
+1 -1
View File
@@ -21,7 +21,7 @@ class WWBOTA(FileDownloadSIGRefDataProvider):
ref_id = row["Reference"]
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["Name"] if "Name" in row else None,
ref_type="Bunker",
url="https://bunkerwiki.org/?s=" + ref_id if ref_id.startswith("B/G") else None,
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,
latitude=float(row["Lat"]) if "Lat" in row and row["Lat"] != "" else None,
longitude=float(row["Long"]) if "Long" in row and row["Long"] != "" else None))
+1 -1
View File
@@ -21,7 +21,7 @@ class WWFF(FileDownloadSIGRefDataProvider):
ref_id = row["reference"]
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=row["name"] if "name" in row else None,
ref_type="Park",
url="https://wwff.co/directory/?showRef=" + ref_id,
url=f"https://wwff.co/directory/?showRef={ref_id}",
grid=row["iaruLocator"] if "iaruLocator" in row and row[
"iaruLocator"] != "-" else None,
latitude=float(row["latitude"]) if "latitude" in row and row[
+1 -1
View File
@@ -27,7 +27,7 @@ class ZLOTA(FileDownloadSIGRefDataProvider):
new_ref = SIGRef(sig=self.SIG, id=ref_id, name=ref["name"],
ref_type=ref["asset_type"].title(),
url="https://ontheair.nz/assets/" + ref_id.replace("/", "_"),
url=f"https://ontheair.nz/assets/{ref_id.replace('/', '_')}",
latitude=latitude,
longitude=longitude)