Files
notifications-admin/domains.py
Chris Hill-Scott 8e3ab35b9a Add a script to output the domains data as a list
This will be useful for putting into a database (it would be hard to
do so in its current, linked format).
2019-02-12 13:40:45 +00:00

31 lines
822 B
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import yaml
from app.utils import AgreementInfo
_dir_path = os.path.dirname(os.path.realpath(__file__))
with open('{}/app/domains.yml'.format(_dir_path)) as source:
data = yaml.load(source)
for domain, details in data.items():
if isinstance(details, dict):
# Were looking at the canonical domain
data[domain]['domains'] = [domain]
for domain, details in data.items():
if isinstance(details, str):
# This is an alias, lets 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)
]
print(yaml.dump(out_data)) # noqa