mirror of
https://github.com/zerwes/ansible-fqcn-converter.git
synced 2025-02-25 18:55:30 -06:00
simple and clean update_fqcn_list.py
This commit is contained in:
parent
3b64af2140
commit
c153a2896c
@ -1,31 +1,15 @@
|
||||
#! /usr/bin/env python3
|
||||
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 smartindent
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import argparse
|
||||
import logging
|
||||
import hiyapyco
|
||||
import requests
|
||||
import json
|
||||
|
||||
__doc__ = """
|
||||
simple script to update the fqcn list
|
||||
"""
|
||||
|
||||
logger = logging.getLogger()
|
||||
logging.basicConfig(
|
||||
level=logging.WARN,
|
||||
format='%(levelname)s\t[%(name)s] %(funcName)s: %(message)s'
|
||||
)
|
||||
|
||||
argparser = argparse.ArgumentParser(description=__doc__)
|
||||
argparser.add_argument(
|
||||
'-c', '--config-files',
|
||||
type=str, nargs='+',
|
||||
dest='configfiles',
|
||||
default=['config.yml',],
|
||||
help='list of config files to use'
|
||||
)
|
||||
argparser.add_argument(
|
||||
'-o', '--out-file',
|
||||
type=str,
|
||||
@ -36,18 +20,19 @@ argparser.add_argument(
|
||||
|
||||
args = argparser.parse_args()
|
||||
|
||||
logger.warning('reading config files: %s', ', '.join(args.configfiles))
|
||||
conf = hiyapyco.load(
|
||||
*args.configfiles,
|
||||
method=hiyapyco.METHOD_MERGE,
|
||||
interpolate=True,
|
||||
failonmissingfiles=True,
|
||||
modulespr = subprocess.run(
|
||||
['ansible-doc', '-lj'],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check = True
|
||||
)
|
||||
|
||||
for org in conf['github_collections_list']:
|
||||
url = 'https://api.github.com/orgs/%s/repos' % org
|
||||
logger.warning('reading repos from %s', url)
|
||||
response = requests.get(url)
|
||||
assert response.status_code == 200
|
||||
response_d = response.json()
|
||||
print(response_d)
|
||||
fqdndict = {}
|
||||
modulesdict = json.loads(modulespr.stdout)
|
||||
for modname in modulesdict.keys():
|
||||
fqdn = modname
|
||||
if '.' not in modname:
|
||||
fqdn = 'ansible.builtin.%s' % modname
|
||||
nonfqdn = fqdn.split('.')[-1]
|
||||
fqdndict[nonfqdn] = fqdn
|
||||
print(fqdndict)
|
||||
|
Loading…
Reference in New Issue
Block a user