| |
@@ -0,0 +1,76 @@
|
| |
+ #!/usr/bin/python3
|
| |
+
|
| |
+ import argparse
|
| |
+ import requests
|
| |
+ import sys
|
| |
+
|
| |
+ def options_parse():
|
| |
+ p = argparse.ArgumentParser(
|
| |
+ description='Find maintainers and their roles given package names')
|
| |
+
|
| |
+ source = p.add_mutually_exclusive_group(required=True)
|
| |
+
|
| |
+ source.add_argument('-f', '--file', type=argparse.FileType('r'), nargs='?',
|
| |
+ help='file containing package names')
|
| |
+ source.add_argument('-p', '--packages', nargs='+',
|
| |
+ help='list of packages to query')
|
| |
+
|
| |
+ p.add_argument('-t', '--type', nargs='?', default='rpms',
|
| |
+ help='{ container | flatpaks | modules | rpms | tests }')
|
| |
+ p.add_argument('-r', '--role', nargs='?', default='admin',
|
| |
+ help='{ admin | epel | fedora }')
|
| |
+ p.add_argument('-v', '--verbose', action='store_true',
|
| |
+ help='Be verbose')
|
| |
+
|
| |
+ opts = p.parse_args()
|
| |
+
|
| |
+ return opts
|
| |
+
|
| |
+ def main():
|
| |
+ opts = options_parse()
|
| |
+
|
| |
+ if opts.file:
|
| |
+ packages = [line.strip() for line in opts.file]
|
| |
+ else:
|
| |
+ packages = opts.packages
|
| |
+
|
| |
+ owners = requests.get('https://src.fedoraproject.org/extras/pagure_owner_alias.json').json()
|
| |
+ roles = requests.get('https://src.fedoraproject.org/extras/pagure_poc.json').json()
|
| |
+
|
| |
+ try:
|
| |
+ by_package = {pkg: owners[opts.type][pkg] for pkg in packages}
|
| |
+ by_package_role = {pkg: roles[opts.type][pkg][opts.role] for pkg in packages}
|
| |
+ except KeyError as e:
|
| |
+ print("Error: No %s by the name of %s" % (opts.type, e))
|
| |
+ exit(1)
|
| |
+
|
| |
+ print(by_package)
|
| |
+ print(by_package_role)
|
| |
+
|
| |
+ by_maintainer = {}
|
| |
+
|
| |
+ print('Maintainers by package:')
|
| |
+ for pkg, maints in sorted(by_package.items()):
|
| |
+ print('{:20}'.format(pkg), end=' ')
|
| |
+ for maint in sorted(maints):
|
| |
+ if by_package_role[pkg] == maint:
|
| |
+ print(maint + ' (' + opts.role + ')', end=' ')
|
| |
+ else:
|
| |
+ print(maint, end=' ')
|
| |
+ by_maintainer.setdefault(maint, []).append(pkg)
|
| |
+ print()
|
| |
+
|
| |
+ print()
|
| |
+ print(by_maintainer)
|
| |
+ print('Packages by maintainer:')
|
| |
+ for maint, pkgs in sorted(by_maintainer.items()):
|
| |
+ print('{:10}'.format(maint), end=' ')
|
| |
+ for pkg in pkgs:
|
| |
+ if by_package_role[pkg] == maint:
|
| |
+ print(pkg + ' (' + opts.role + ')', end=' ')
|
| |
+ else:
|
| |
+ print(pkg, end=' ')
|
| |
+ print()
|
| |
+
|
| |
+ if __name__ == '__main__':
|
| |
+ main()
|
| |
Adoption of find-package-maintainers listing role of maintainer
in relation to package (both ways).