diff options
author | Gilles Dartiguelongue <eva@gentoo.org> | 2015-06-25 14:47:22 +0200 |
---|---|---|
committer | Gilles Dartiguelongue <eva@gentoo.org> | 2015-06-27 00:14:40 +0200 |
commit | 19c52766c8ca16879f8b03b3f6a9b85c0865a04f (patch) | |
tree | c308567716dcb4f72788bd7cae9917f5d9689972 /scripts | |
parent | scripts/gen_archlist: add full CPV lines to our workset (diff) | |
download | gnome-19c52766c8ca16879f8b03b3f6a9b85c0865a04f.tar.gz gnome-19c52766c8ca16879f8b03b3f6a9b85c0865a04f.tar.bz2 gnome-19c52766c8ca16879f8b03b3f6a9b85c0865a04f.zip |
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.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gen_archlist.py | 75 |
1 files changed, 28 insertions, 47 deletions
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py index f9cf432b..066b31e1 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__': |