From 5a77b6a8e5ba19fb48f3f3c4ec9eefaa51b449fc Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Wed, 30 Dec 2020 21:37:25 +0100 Subject: [PATCH] show bandplan bookmarks only when mode is available --- owrx/bands.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/owrx/bands.py b/owrx/bands.py index fbb7ae6..89bf293 100644 --- a/owrx/bands.py +++ b/owrx/bands.py @@ -1,3 +1,4 @@ +from owrx.modes import Modes import json import logging @@ -12,7 +13,15 @@ class Band(object): self.upper_bound = dict["upper_bound"] self.frequencies = [] if "frequencies" in dict: + availableModes = [mode.modulation for mode in Modes.getAvailableModes()] for (mode, freqs) in dict["frequencies"].items(): + if mode not in availableModes: + logger.info( + "Modulation \"{mode}\" is not available, bandplan bookmark will not be displayed".format( + mode=mode + ) + ) + continue if not isinstance(freqs, list): freqs = [freqs] for f in freqs: @@ -22,8 +31,8 @@ class Band(object): mode=mode, frequency=f, band=self.name ) ) - else: - self.frequencies.append({"mode": mode, "frequency": f}) + continue + self.frequencies.append({"mode": mode, "frequency": f}) def inBand(self, freq): return self.lower_bound <= freq <= self.upper_bound