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
|
#! /usr/bin/env python3
|
||||||
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 smartindent
|
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 smartindent
|
||||||
|
|
||||||
import os
|
import subprocess
|
||||||
import sys
|
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import json
|
||||||
import hiyapyco
|
|
||||||
import requests
|
|
||||||
|
|
||||||
__doc__ = """
|
__doc__ = """
|
||||||
simple script to update the fqcn list
|
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 = 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(
|
argparser.add_argument(
|
||||||
'-o', '--out-file',
|
'-o', '--out-file',
|
||||||
type=str,
|
type=str,
|
||||||
@ -36,18 +20,19 @@ argparser.add_argument(
|
|||||||
|
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
|
|
||||||
logger.warning('reading config files: %s', ', '.join(args.configfiles))
|
modulespr = subprocess.run(
|
||||||
conf = hiyapyco.load(
|
['ansible-doc', '-lj'],
|
||||||
*args.configfiles,
|
stdout=subprocess.PIPE,
|
||||||
method=hiyapyco.METHOD_MERGE,
|
stderr=subprocess.PIPE,
|
||||||
interpolate=True,
|
check = True
|
||||||
failonmissingfiles=True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
for org in conf['github_collections_list']:
|
fqdndict = {}
|
||||||
url = 'https://api.github.com/orgs/%s/repos' % org
|
modulesdict = json.loads(modulespr.stdout)
|
||||||
logger.warning('reading repos from %s', url)
|
for modname in modulesdict.keys():
|
||||||
response = requests.get(url)
|
fqdn = modname
|
||||||
assert response.status_code == 200
|
if '.' not in modname:
|
||||||
response_d = response.json()
|
fqdn = 'ansible.builtin.%s' % modname
|
||||||
print(response_d)
|
nonfqdn = fqdn.split('.')[-1]
|
||||||
|
fqdndict[nonfqdn] = fqdn
|
||||||
|
print(fqdndict)
|
||||||
|
Loading…
Reference in New Issue
Block a user