From 233149cb88b605caab5cc8397b425937a7369b6a Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Oct 05 2018 20:51:09 +0000 Subject: [PATCH 1/3] Split out inheritance flags formatting --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 5b89b0c..c8753f1 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -40,7 +40,7 @@ from koji_cli.lib import _, OptionParser, activate_session, parse_arches, \ _unique_path, _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, greetings, _list_tasks, unique_path + error, greetings, _list_tasks, unique_path, format_inheritance_flags def _printable_unicode(s): @@ -4670,17 +4670,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(tag, **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 f4bce0f..e8f360b 100644 --- a/cli/koji_cli/lib.py +++ b/cli/koji_cli/lib.py @@ -649,3 +649,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 From 85bc67c92f64be5fc51984271ec779de69830858 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Oct 05 2018 20:51:28 +0000 Subject: [PATCH 2/3] display flags in list-tag-inheritance --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index c8753f1..728db4a 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -3773,10 +3773,11 @@ def _printInheritance(tags, sibdepths=None, reverse=False): else: sys.stdout.write(_printable_unicode(u'\u2514')) sys.stdout.write(_printable_unicode(u'\u2500')) + currtag['flags'] = format_inheritance_flags(currtag) if reverse: - sys.stdout.write('%(name)s (%(tag_id)i)\n' % currtag) + sys.stdout.write('%(name)s (%(tag_id)i) %(flags)s\n' % currtag) else: - sys.stdout.write('%(name)s (%(parent_id)i)\n' % currtag) + sys.stdout.write('%(name)s (%(parent_id)i) %(flags)s\n' % currtag) if siblings: if len(sibdepths) == 0 or sibdepths[-1] != currtag['currdepth']: From 4f252ca6659cfff1a5f7ceae666ad84d2dd1c75c Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Aug 13 2019 16:09:44 +0000 Subject: [PATCH 3/3] move flags to front --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 728db4a..bd98ae6 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -3767,17 +3767,17 @@ 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')) else: sys.stdout.write(_printable_unicode(u'\u2514')) sys.stdout.write(_printable_unicode(u'\u2500')) - currtag['flags'] = format_inheritance_flags(currtag) if reverse: - sys.stdout.write('%(name)s (%(tag_id)i) %(flags)s\n' % currtag) + sys.stdout.write('%(name)s (%(tag_id)i)\n' % currtag) else: - sys.stdout.write('%(name)s (%(parent_id)i) %(flags)s\n' % currtag) + sys.stdout.write('%(name)s (%(parent_id)i)\n' % currtag) if siblings: if len(sibdepths) == 0 or sibdepths[-1] != currtag['currdepth']: @@ -3840,7 +3840,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'])