Esempio n. 1
0
def main():
    args = objectview(docopt.docopt(__doc__))
    if args.website:
        website(args)
    elif args.data:
        # TODO - allow basic exploration of the data
        pass
    elif args.db:
        if args.create:
            load_tracker_db(loc='tracker.db')
        elif args.dump:
            # TODO: Replace this with `pathlib`
            tracker_db_path = os.path.join(os.path.dirname(__file__), 'data',
                                           'assets', 'trackerdb.sql')
            conn = sqlite3.connect('tracker.db')
            with open(tracker_db_path, 'w') as fp:
                for line in conn.iterdump():
                    fp.write('%s\n' % line)
        elif args.check_urls:
            needqa = Path('needqa')
            if not needqa.exists():
                needqa.mkdir()
            https_upgrade = upgrade_to_https(tracker_db='tracker.db')
            create_task_files(needqa_folder=needqa, **https_upgrade)
        elif args.json:
            db_map = create_tracker_map(load_tracker_db(),
                                        with_iab_vendors=True)
            print(json.dumps(db_map, indent=2, sort_keys=True))
Esempio n. 2
0
    def __init__(self, region="global"):
        self.data_months = sorted(list_available_months(region=region))
        print('data available for months:\n├──',
              "\n├── ".join(self.data_months))

        # Add demographics info to trackers and companies
        connection = load_tracker_db()
        tracker_map = create_tracker_map(connection)
        self.app_info = tracker_map['trackers']
        self.company_info = tracker_map['companies']

        self.sites_trackers = SitesTrackers(
            data_months=[max(self.data_months)],
            tracker_info=self.app_info,
            region=region)
        self.trackers = Trackers(data_months=self.data_months,
                                 tracker_info=self.app_info,
                                 sites=self.sites_trackers,
                                 region=region)
        self.companies = Companies(data_months=self.data_months,
                                   company_info=self.company_info,
                                   tracker_info=self.app_info,
                                   region=region)
        self.sites = Sites(data_months=self.data_months,
                           trackers=self.sites_trackers,
                           region=region)
Esempio n. 3
0
def build_tracker_db():
    with open('_site/data/trackerdb.json', 'w') as output:
        db_map = create_tracker_map(load_tracker_db(), with_iab_vendors=True)
        db_map['about'] = 'WhoTracks.Me tracker database: whotracks.me'
        json.dump(db_map, output, indent=2, sort_keys=True)