|
|
db3f8ce |
#!/usr/bin/python3
|
|
|
db3f8ce |
|
|
|
db3f8ce |
import argparse
|
|
|
db3f8ce |
import json
|
|
|
db3f8ce |
import sys
|
|
|
db3f8ce |
|
|
|
db3f8ce |
def main():
|
|
|
db3f8ce |
parser = argparse.ArgumentParser()
|
|
|
db3f8ce |
group = parser.add_mutually_exclusive_group(required=True)
|
|
|
db3f8ce |
group.add_argument("-P", "--provides", action="store_const", const="provides", dest="action")
|
|
|
db3f8ce |
group.add_argument("-R", "--requires", action="store_const", const="requires", dest="action")
|
|
|
db3f8ce |
args = parser.parse_args()
|
|
|
db3f8ce |
|
|
|
db3f8ce |
files = sys.stdin.read().splitlines()
|
|
|
db3f8ce |
|
|
|
db3f8ce |
for f in files:
|
|
|
db3f8ce |
with open(f, "r") as fobj:
|
|
|
db3f8ce |
info = json.load(fobj)['collection_info']
|
|
|
db3f8ce |
if args.action == "provides":
|
|
|
db3f8ce |
print(f"ansible-collection({info['namespace']}.{info['name']}) = {info['version']}")
|
|
|
db3f8ce |
if args.action == "requires":
|
|
|
db3f8ce |
print("(ansible >= 2.9.0 with ansible < 2.10.0)")
|
|
|
db3f8ce |
if info['dependencies']:
|
|
|
db3f8ce |
raise NotImplementedError('Generation of dependencies is not supported yet')
|
|
|
db3f8ce |
|
|
|
db3f8ce |
if __name__ == "__main__":
|
|
|
db3f8ce |
main()
|