From 7177011427baf6fcc82394355566ef333ea63dfa Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 5 Apr 2019 12:05:25 +0100 Subject: [PATCH] Delete domains.py It was temporarily used to export data from `domains.yml` into a format that could be migrated into the database. --- domains.py | 52 ---------------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100755 domains.py diff --git a/domains.py b/domains.py deleted file mode 100755 index 3cb1245a8..000000000 --- a/domains.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import os -import yaml -from itertools import chain -from operator import itemgetter -from sys import argv -from app.utils import AgreementInfo - -_dir_path = os.path.dirname(os.path.realpath(__file__)) - - -if len(argv) < 2: - raise TypeError('Must specify `orgs` or `domains` as the first argument to this script') - - -with open('{}/app/domains.yml'.format(_dir_path)) as source: - - data = yaml.load(source) - - for domain, details in data.items(): - if isinstance(details, dict): - # We’re looking at the canonical domain - data[domain]['domains'] = [domain] - - for domain, details in data.items(): - if isinstance(details, str): - # This is an alias, let’s add it to the canonical domain - data[AgreementInfo(domain).canonical_domain]['domains'].append(domain) - - out_data = [ - details for domain, details in data.items() - if isinstance(details, dict) - ] - - if argv[1] == 'orgs': - print(yaml.dump(out_data)) # noqa - elif argv[1] == 'domains': - print( # noqa - sorted( - set( - chain.from_iterable( - map( - itemgetter('domains'), out_data - ) - ) - ) - ) - ) - else: - raise TypeError('Must specify `orgs` or `domains` as the first argument to this script')