summaryrefslogtreecommitdiffstats
path: root/Src/PyCatcher/src/filters.py
blob: b574ade1dcb690239eb0dd331963ab4cb1117423 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Filter:
    def __init__(self):
        self.is_active = False
        self.params = {}
        
    def execute(self, station_list):
        raise NotImplementedError('Filter not yet implemented')

class BandFilter(Filter):
    band = 0

    def execute(self, station_list):
        raise NotImplementedError('Band Filters should not be executed!')

class ARFCNFilter(Filter):
    def execute(self, station_list):
        filtered_list = []
        low = self.params['from']
        high = self.params['to']
        for station in station_list:
            if station.arfcn <= high and station.arfcn >= low:
                filtered_list.append(station) 
        return filtered_list
    
class ProviderFilter(Filter):
    def execute(self, station_list):
        filtered_list = []
        providers  = [x.strip() for x in self.params['providers'].split(',')]
        for station in station_list:
            if station.provider in providers:
                filtered_list.append(station) 
        return filtered_list

class BandFilter900(BandFilter):
    band = 900