Use ruff linter to fix issues and provide consistent formatting

This commit is contained in:
Ian Renton
2026-08-15 08:25:54 +01:00
parent 7391c28cd0
commit af3f82c14d
121 changed files with 1989 additions and 996 deletions
+4 -2
View File
@@ -5,7 +5,9 @@ import geopandas
from shapely import prepare
from core.data_store import DATA_STORE
from providers.staticdata.local_file_static_data_provider import LocalFileStaticDataProvider
from providers.staticdata.local_file_static_data_provider import (
LocalFileStaticDataProvider,
)
class CQZoneData(LocalFileStaticDataProvider):
@@ -21,7 +23,7 @@ class CQZoneData(LocalFileStaticDataProvider):
with open(path) as f:
cq_zone_data = geopandas.GeoDataFrame.from_features(json.load(f)["features"])
for idx in cq_zone_data.index:
prepare(cq_zone_data.at[idx, 'geometry'])
prepare(cq_zone_data.at[idx, "geometry"])
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to prepare the rest
# of the data in this case
@@ -1,6 +1,6 @@
import logging
from datetime import datetime
from threading import Thread, Event
from threading import Event, Thread
import pytz
from requests import ReadTimeout
@@ -13,10 +13,10 @@ from providers.staticdata.static_data_provider import StaticDataProvider
class FileDownloadStaticDataProvider(StaticDataProvider):
"""Generic static reference data provider class for providers that fetch their data from the web by downloading a
file."""
file."""
def __init__(self, name, provider_config, url, poll_interval):
""" Set up the provider, note poll_interval is in *days*."""
"""Set up the provider, note poll_interval is in *days*."""
super().__init__(name, provider_config)
self._url = url
self._poll_interval = poll_interval
@@ -27,8 +27,7 @@ class FileDownloadStaticDataProvider(StaticDataProvider):
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(
f"Set up query of {self.name} static reference data every {self._poll_interval!s} days.")
logging.info(f"Set up query of {self.name} static reference data every {self._poll_interval!s} days.")
self._thread = Thread(target=self._run, name=f"FileDownloadStaticDataProvider-{self.name}")
self._thread.start()
@@ -57,7 +56,9 @@ class FileDownloadStaticDataProvider(StaticDataProvider):
logging.info(f"Updated static reference data for {self.name}")
else:
self.status = "Error"
logging.warning(f"HTTP {http_response.status_code} when downloading static reference data for {self.name}.")
logging.warning(
f"HTTP {http_response.status_code} when downloading static reference data for {self.name}."
)
except ConnectionError:
self.status = "Error"
@@ -72,6 +73,6 @@ class FileDownloadStaticDataProvider(StaticDataProvider):
def _handle_http_response(self, http_response):
"""Handle an HTTP response returned by the server and load the data from it. Return true if successful,
false otherwise."""
false otherwise."""
raise NotImplementedError("Subclasses must implement this method")
+4 -2
View File
@@ -5,7 +5,9 @@ import geopandas
from shapely import prepare
from core.data_store import DATA_STORE
from providers.staticdata.local_file_static_data_provider import LocalFileStaticDataProvider
from providers.staticdata.local_file_static_data_provider import (
LocalFileStaticDataProvider,
)
class ITUZoneData(LocalFileStaticDataProvider):
@@ -21,7 +23,7 @@ class ITUZoneData(LocalFileStaticDataProvider):
with open(path) as f:
itu_zone_data = geopandas.GeoDataFrame.from_features(json.load(f)["features"])
for idx in itu_zone_data.index:
prepare(itu_zone_data.at[idx, 'geometry'])
prepare(itu_zone_data.at[idx, "geometry"])
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to prepare the rest
# of the data in this case
+3 -3
View File
@@ -1,7 +1,9 @@
import logging
from core.data_store import DATA_STORE
from providers.staticdata.file_download_static_data_provider import FileDownloadStaticDataProvider
from providers.staticdata.file_download_static_data_provider import (
FileDownloadStaticDataProvider,
)
class K0SWE(FileDownloadStaticDataProvider):
@@ -44,5 +46,3 @@ class K0SWE(FileDownloadStaticDataProvider):
except Exception:
logging.exception("Exception when loading K0SWE dxcc.json.")
return False
@@ -15,13 +15,11 @@ class StaticDataProvider:
self.status = "Not Started" if self.enabled else "Disabled"
self.reference_count = 0
def start(self):
"""Start the provider. This should return immediately after spawning threads to access the remote resources"""
raise NotImplementedError("Subclasses must implement this method")
def stop(self):
"""Stop any threads and prepare for application shutdown"""