#8 Find package maintainers and their role
Opened 2 years ago by gui1ty. Modified 2 years ago
gui1ty/fedora-misc-package-utilities master  into  master

file modified
+17
@@ -48,3 +48,20 @@ 

  

  This lists all orphaned packages that are not retired on master.

  Needs Python 3.7 and aiohttp.

+ 

+ find-package-maintainers-role

+ -----------------------------

+ 

+ Accepts either file with package names (one per line) (-f) or package names (-p).

+ 

+ Allows to specify package type (-t) (default: rpms) and role (-r) (default: admin)

+ to search for.

+ 

+ Errors in package names are handled.

+ 

+ Outputs two lists to stdout:

+ 

+ * All maintainers per package with given role added in ()

+ 

+ * All packages per maintainer with given role added in ()

+ 

@@ -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).

  • allows file input (-f)
  • allows direct package input (-p)
  • specify type of package (-t)
  • specify role (-r)
  • does error handling if package isn't found

I had to scratch an itch (someone else's itch, actually) :bug:

Metadata