summaryrefslogtreecommitdiffstats
path: root/Src/PyCatcher/src/filters.py
blob: 07cba419d3cdc63d301d550300466424b65192b3 (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
class Filter:
    def __init__(self):
        self.is_active = False
        self.params = {}
        
    def execute(self, station_list):
        raise NotImplementedError('Filter not yet implemented')

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