From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 86F20138CEE for ; Fri, 26 Jun 2015 22:32:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EBBD9E086C; Fri, 26 Jun 2015 22:32:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 9BE22E0866 for ; Fri, 26 Jun 2015 22:32:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B0629340A27 for ; Fri, 26 Jun 2015 22:32:07 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id DACAA73A for ; Fri, 26 Jun 2015 22:32:03 +0000 (UTC) From: "Gilles Dartiguelongue" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Gilles Dartiguelongue" Message-ID: <1435356880.19c52766c8ca16879f8b03b3f6a9b85c0865a04f.eva@gentoo> Subject: [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/ X-VCS-Repository: proj/gnome X-VCS-Files: scripts/gen_archlist.py X-VCS-Directories: scripts/ X-VCS-Committer: eva X-VCS-Committer-Name: Gilles Dartiguelongue X-VCS-Revision: 19c52766c8ca16879f8b03b3f6a9b85c0865a04f X-VCS-Branch: gen_archlist_cleanup Date: Fri, 26 Jun 2015 22:32:03 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 6cd6f10a-55c9-4e5e-81d0-1fe43c70ff59 X-Archives-Hash: e01a8db603b8e69133f3ddd7ec77c070 commit: 19c52766c8ca16879f8b03b3f6a9b85c0865a04f Author: Gilles Dartiguelongue gentoo org> AuthorDate: Thu Jun 25 12:47:22 2015 +0000 Commit: Gilles Dartiguelongue gentoo org> CommitDate: Fri Jun 26 22:14:40 2015 +0000 URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=19c52766 scripts/gen_archlist: make prettify the print function No need for another function call at this point, everything that happens in prettify is only intended for output. scripts/gen_archlist.py | 75 ++++++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 47 deletions(-) diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py index f9cf432..066b31e 100755 --- a/scripts/gen_archlist.py +++ b/scripts/gen_archlist.py @@ -21,7 +21,7 @@ # * Support recursive checking of needed keywords in deps # -from __future__ import division +from __future__ import division, print_function import argparse import collections @@ -392,52 +392,34 @@ def append_slots(cpv_kws): return slotifyed_cpv_kws -# FIXME: This is broken -def prettify(cpv_kws): - "Takes a list of [cpv, [kws]] and prettifies it" +def print_cpv_kws(cpv_kws): + """Takes a list of [cpv, [kws]] and prettifies it""" max_len = 0 - kws_all = [] - pretty_list = [] - cpv_block_size = 0 + kws_all = set() - for each in cpv_kws: - # Ignore comments/whitespace carried over from original list - if type(each) is not list: - continue - # Find the atom with max length (for output formatting) - if len(each[0]) > max_len: - max_len = len(each[0]) - # Find the set of all kws listed - for kw in each[1]: - if kw not in kws_all: - kws_all.append(kw) - kws_all.sort() - - for each in cpv_kws: - # Handle comments/whitespace carried over from original list - if type(each) is not list: - # If the prev cpv block has just one line, don't print an extra \n - # XXX: This code relies on blocks of dep-cpvs being separated by \n - if CHECK_DEPS and cpv_block_size is 1: - cpv_block_size = 0 - continue - pretty_list.append([each, []]) - cpv_block_size = 0 - continue - # The size of the current cpv list block - cpv_block_size += 1 - # Pad the cpvs with space - each[0] += n_sep(max_len - len(each[0])) - for i in range(0, len(kws_all)): - if i == len(each[1]): - # Prevent an IndexError - # This is a problem in the algo I selected - each[1].append('') - if each[1][i] != kws_all[i]: - # If no arch, insert space - each[1].insert(i, n_sep(len(kws_all[i]))) - pretty_list.append([each[0], each[1]]) - return pretty_list + for dep_set in cpv_kws: + for cpv, kws in dep_set: + # Find the atom with max length (for output formatting) + max_len = max(max_len, len(cpv)) + # Find the set of all kws listed + kws_all.update(kws) + + for dep_set in cpv_kws: + for cpv, kws in dep_set: + pretty_line = cpv + ' ' * (max_len - len(cpv)) + + for kwd in sorted(kws_all): + if kwd in kws: + pretty_line += ' ' + kwd + else: + pretty_line += ' ' + ' ' * len(kwd) + + print(pretty_line) + + if len(dep_set) > 1: + print() + + return ##################### @@ -511,8 +493,7 @@ def main(): if args.append_slots: ALL_CPV_KWS = append_slots(ALL_CPV_KWS) - for i in prettify(ALL_CPV_KWS): - print i[0], flatten(i[1]) + print_cpv_kws(ALL_CPV_KWS) if __name__ == '__main__':