mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
More ruff linter fixes
This commit is contained in:
@@ -150,7 +150,7 @@ def get_alert_list_with_filters(all_alerts, query):
|
||||
alerts.append(a)
|
||||
alerts = sorted(alerts, key=lambda alert: alert.start_time if alert and alert.start_time else 0)
|
||||
alerts = list(filter(lambda alert: alert_allowed_by_query(alert, query), alerts))
|
||||
if "limit" in query.keys():
|
||||
if "limit" in query:
|
||||
alerts = alerts[: int(query.get("limit"))]
|
||||
return alerts
|
||||
|
||||
@@ -159,7 +159,7 @@ def alert_allowed_by_query(alert, query):
|
||||
"""Given URL query params and an alert, figure out if the alert "passes" the requested filters or is rejected. The list
|
||||
of query parameters and their function is defined in the API docs."""
|
||||
|
||||
for k in query.keys():
|
||||
for k in query:
|
||||
match k:
|
||||
case "received_since":
|
||||
since = datetime.fromtimestamp(float(query.get(k)), pytz.UTC)
|
||||
@@ -172,7 +172,7 @@ def alert_allowed_by_query(alert, query):
|
||||
# the alert is a dxpedition, it also always passes the check.
|
||||
if alert.is_dxpedition and (
|
||||
query.get("dxpeditions_skip_max_duration_check").upper() == "TRUE"
|
||||
if "dxpeditions_skip_max_duration_check" in query.keys()
|
||||
if "dxpeditions_skip_max_duration_check" in query
|
||||
else False
|
||||
):
|
||||
continue
|
||||
|
||||
@@ -47,7 +47,7 @@ class APIDxStatsHandler(tornado.web.RequestHandler):
|
||||
one_hour_ago = (datetime.now(pytz.UTC) - timedelta(hours=1)).timestamp()
|
||||
counts = Counter()
|
||||
|
||||
for key in self._spots.keys():
|
||||
for key in self._spots:
|
||||
spot = self._spots.get(key)
|
||||
if spot is None:
|
||||
continue
|
||||
|
||||
@@ -108,7 +108,7 @@ class APILookupSIGRefHandler(tornado.web.RequestHandler):
|
||||
if "sig" in query_params and "id" in query_params:
|
||||
sig = str(query_params.get("sig")).upper()
|
||||
ref_id = str(query_params.get("id")).upper()
|
||||
if sig in list(map(lambda p: p.name.upper(), SIGS)):
|
||||
if sig in [p.name.upper() for p in SIGS]:
|
||||
if not get_ref_regex_for_sig(sig) or re.match(get_ref_regex_for_sig(sig), ref_id):
|
||||
data = populate_missing_sig_ref_info(SIGRef(id=ref_id, sig=sig))
|
||||
self.write(safe_json_dumps(data))
|
||||
|
||||
@@ -62,36 +62,16 @@ class APIOptionsHandler(tornado.web.RequestHandler):
|
||||
|
||||
# Spot/alert sources are filtered for only ones that are enabled in config, no point letting the user toggle
|
||||
# things that aren't even available.
|
||||
spot_providers: list = list(
|
||||
map(
|
||||
lambda p: p["name"],
|
||||
filter(lambda p: p["enabled"], self._status_data["spot_providers"]),
|
||||
)
|
||||
)
|
||||
alert_providers = list(
|
||||
map(
|
||||
lambda p: p["name"],
|
||||
filter(lambda p: p["enabled"], self._status_data["alert_providers"]),
|
||||
)
|
||||
)
|
||||
callsign_data_providers = list(
|
||||
map(
|
||||
lambda p: p["name"],
|
||||
filter(
|
||||
spot_providers: list = [p["name"] for p in filter(lambda p: p["enabled"], self._status_data["spot_providers"])]
|
||||
alert_providers = [p["name"] for p in filter(lambda p: p["enabled"], self._status_data["alert_providers"])]
|
||||
callsign_data_providers = [p["name"] for p in filter(
|
||||
lambda p: p["enabled"],
|
||||
self._status_data["callsign_data_providers"],
|
||||
),
|
||||
)
|
||||
)
|
||||
spot_providers_enabled_by_default = list(
|
||||
map(
|
||||
lambda p: p["name"],
|
||||
filter(
|
||||
)]
|
||||
spot_providers_enabled_by_default = [p["name"] for p in filter(
|
||||
lambda p: p["enabled"] and p["enabled_by_default_in_web_ui"],
|
||||
self._status_data["spot_providers"],
|
||||
),
|
||||
)
|
||||
)
|
||||
)]
|
||||
|
||||
# If spotting to this server is enabled, "API" is another valid spot source even though it does not come from
|
||||
# one of our providers.
|
||||
|
||||
@@ -153,7 +153,7 @@ def get_spot_list_with_filters(all_spots, query):
|
||||
spots.append(s)
|
||||
spots = sorted(spots, key=lambda spot: spot.time if spot and spot.time else 0, reverse=True)
|
||||
spots = list(filter(lambda spot: spot_allowed_by_query(spot, query), spots))
|
||||
if "limit" in query.keys():
|
||||
if "limit" in query:
|
||||
spots = spots[: int(query.get("limit"))]
|
||||
|
||||
# Ensure only the latest spot of each callsign-SSID combo is present in the list. This relies on the
|
||||
@@ -163,7 +163,7 @@ def get_spot_list_with_filters(all_spots, query):
|
||||
# This is a special consideration for the geo map and band map views (and Field Spotter) because while
|
||||
# duplicates are fine in the main spot list (e.g. different cluster spots of the same DX) this doesn't
|
||||
# work well for the other views.
|
||||
if "dedupe" in query.keys():
|
||||
if "dedupe" in query:
|
||||
dedupe = query.get("dedupe").upper() == "TRUE"
|
||||
if dedupe:
|
||||
spots_temp = []
|
||||
@@ -182,7 +182,7 @@ def spot_allowed_by_query(spot, query):
|
||||
"""Given URL query params and a spot, figure out if the spot "passes" the requested filters or is rejected. The list
|
||||
of query parameters and their function is defined in the API docs."""
|
||||
|
||||
for k in query.keys():
|
||||
for k in query:
|
||||
match k:
|
||||
case "since":
|
||||
since = datetime.fromtimestamp(int(query.get(k)), pytz.UTC).timestamp()
|
||||
|
||||
Reference in New Issue
Block a user