From 8e5489627610d8c3d73b17851260f304323b9999 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Oct 15 2019 06:51:11 +0000 Subject: PR#1120: Show inheritance flags in list-tag-inheritance output Merges #1120 https://pagure.io/koji/pull-request/1120 Fixes: #1625 Show in inheritance flags in inheritance listing https://pagure.io/koji/issue/1625 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 0d572bf..e95b0cb 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -40,7 +40,8 @@ from koji_cli.lib import _, activate_session, parse_arches, \ _running_in_bg, _progress_callback, watch_tasks, \ arg_filter, linked_upload, list_task_output_all_volumes, \ print_task_headers, print_task_recurse, download_file, watch_logs, \ - error, warn, greetings, _list_tasks, unique_path + error, warn, greetings, _list_tasks, unique_path, \ + format_inheritance_flags def _printable_unicode(s): @@ -3996,6 +3997,7 @@ def _printInheritance(tags, sibdepths=None, reverse=False): sys.stdout.write(_printable_unicode(u'\u2502')) outdepth = depth + sys.stdout.write(format_inheritance_flags(currtag)) sys.stdout.write(' ' * ((currtag['currdepth'] - outdepth) * 3 - 1)) if siblings: sys.stdout.write(_printable_unicode(u'\u251c')) @@ -4068,7 +4070,7 @@ def anon_handle_list_tag_inheritance(goptions, session, args): parser.error(_("Unknown tag: %s" % options.stop)) opts['stops'] = {str(tag1): 1} - sys.stdout.write('%s (%i)\n' % (tag['name'], tag['id'])) + sys.stdout.write(' %s (%i)\n' % (tag['name'], tag['id'])) data = session.getFullInheritance(tag['id'], **opts) _printInheritance(data, None, opts['reverse']) @@ -4912,17 +4914,7 @@ def anon_handle_taginfo(goptions, session, args): print(" %(priority)3i %(external_repo_name)s (%(url)s)" % rinfo) print("Inheritance:") for parent in session.getInheritanceData(info['id'], **event_opts): - flags = '' - for code,expr in ( - ('M',parent['maxdepth'] is not None), - ('F',parent['pkg_filter']), - ('I',parent['intransitive']), - ('N',parent['noconfig']),): - if expr: - flags += code - else: - flags += '.' - parent['flags'] = flags + parent['flags'] = format_inheritance_flags(parent) print(" %(priority)-4d %(flags)s %(name)s [%(parent_id)s]" % parent) if parent['maxdepth'] is not None: print(" maxdepth: %(maxdepth)s" % parent) diff --git a/cli/koji_cli/lib.py b/cli/koji_cli/lib.py index 5c62be1..9dbadc7 100644 --- a/cli/koji_cli/lib.py +++ b/cli/koji_cli/lib.py @@ -636,3 +636,18 @@ def _list_tasks(options, session): t['sub'] = True return tasklist + + +def format_inheritance_flags(parent): + """Return a human readable string of inheritance flags""" + flags = '' + for code,expr in ( + ('M', parent['maxdepth'] is not None), + ('F', parent['pkg_filter']), + ('I', parent['intransitive']), + ('N', parent['noconfig']),): + if expr: + flags += code + else: + flags += '.' + return flags