show bandplan bookmarks only when mode is available
This commit is contained in:
		@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					from owrx.modes import Modes
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
@@ -12,7 +13,15 @@ class Band(object):
 | 
				
			|||||||
        self.upper_bound = dict["upper_bound"]
 | 
					        self.upper_bound = dict["upper_bound"]
 | 
				
			||||||
        self.frequencies = []
 | 
					        self.frequencies = []
 | 
				
			||||||
        if "frequencies" in dict:
 | 
					        if "frequencies" in dict:
 | 
				
			||||||
 | 
					            availableModes = [mode.modulation for mode in Modes.getAvailableModes()]
 | 
				
			||||||
            for (mode, freqs) in dict["frequencies"].items():
 | 
					            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):
 | 
					                if not isinstance(freqs, list):
 | 
				
			||||||
                    freqs = [freqs]
 | 
					                    freqs = [freqs]
 | 
				
			||||||
                for f in freqs:
 | 
					                for f in freqs:
 | 
				
			||||||
@@ -22,8 +31,8 @@ class Band(object):
 | 
				
			|||||||
                                mode=mode, frequency=f, band=self.name
 | 
					                                mode=mode, frequency=f, band=self.name
 | 
				
			||||||
                            )
 | 
					                            )
 | 
				
			||||||
                        )
 | 
					                        )
 | 
				
			||||||
                    else:
 | 
					                        continue
 | 
				
			||||||
                        self.frequencies.append({"mode": mode, "frequency": f})
 | 
					                    self.frequencies.append({"mode": mode, "frequency": f})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def inBand(self, freq):
 | 
					    def inBand(self, freq):
 | 
				
			||||||
        return self.lower_bound <= freq <= self.upper_bound
 | 
					        return self.lower_bound <= freq <= self.upper_bound
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user