mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
Add option to output just domains from script
This commit is contained in:
24
domains.py
24
domains.py
@@ -3,11 +3,18 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
|
from itertools import chain
|
||||||
|
from operator import itemgetter
|
||||||
|
from sys import argv
|
||||||
from app.utils import AgreementInfo
|
from app.utils import AgreementInfo
|
||||||
|
|
||||||
_dir_path = os.path.dirname(os.path.realpath(__file__))
|
_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:
|
with open('{}/app/domains.yml'.format(_dir_path)) as source:
|
||||||
|
|
||||||
data = yaml.load(source)
|
data = yaml.load(source)
|
||||||
@@ -27,4 +34,19 @@ with open('{}/app/domains.yml'.format(_dir_path)) as source:
|
|||||||
if isinstance(details, dict)
|
if isinstance(details, dict)
|
||||||
]
|
]
|
||||||
|
|
||||||
print(yaml.dump(out_data)) # noqa
|
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')
|
||||||
|
|||||||
Reference in New Issue
Block a user