def setUpClass(cls): cls.conn = load_tracker_db()
def setUp(self): self.conn = load_tracker_db() self.ds = DataSource()
def setUp(self): self.conn = load_tracker_db()
from collections import defaultdict, Counter from whotracksme.data import load_tracker_db, load_apps # Categories to tracker domains trackers_by_category = defaultdict(list) tracker_domains_to_app = {} # Load trackers and group them by category sql_query = """ SELECT categories.name, tracker, domain FROM tracker_domains INNER JOIN trackers ON trackers.id = tracker_domains.tracker INNER JOIN categories ON categories.id = trackers.category_id; """ with load_tracker_db() as connection: for (category, tracker, domain) in connection.execute(sql_query): trackers_by_category[category].append(domain) tracker_domains_to_app[domain] = tracker print(trackers_by_category) apps = load_apps() def filter_domains(domains): for domain in domains: app_name = tracker_domains_to_app[domain] if app_name in apps: app = apps[tracker_domains_to_app[domain]] tracked = app['overview']['tracked'] if tracked >= 0.1: yield domain