1 |
commit: 19c52766c8ca16879f8b03b3f6a9b85c0865a04f |
2 |
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 25 12:47:22 2015 +0000 |
4 |
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jun 26 22:14:40 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=19c52766 |
7 |
|
8 |
scripts/gen_archlist: make prettify the print function |
9 |
|
10 |
No need for another function call at this point, everything that happens |
11 |
in prettify is only intended for output. |
12 |
|
13 |
scripts/gen_archlist.py | 75 ++++++++++++++++++------------------------------- |
14 |
1 file changed, 28 insertions(+), 47 deletions(-) |
15 |
|
16 |
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py |
17 |
index f9cf432..066b31e 100755 |
18 |
--- a/scripts/gen_archlist.py |
19 |
+++ b/scripts/gen_archlist.py |
20 |
@@ -21,7 +21,7 @@ |
21 |
# * Support recursive checking of needed keywords in deps |
22 |
# |
23 |
|
24 |
-from __future__ import division |
25 |
+from __future__ import division, print_function |
26 |
|
27 |
import argparse |
28 |
import collections |
29 |
@@ -392,52 +392,34 @@ def append_slots(cpv_kws): |
30 |
return slotifyed_cpv_kws |
31 |
|
32 |
|
33 |
-# FIXME: This is broken |
34 |
-def prettify(cpv_kws): |
35 |
- "Takes a list of [cpv, [kws]] and prettifies it" |
36 |
+def print_cpv_kws(cpv_kws): |
37 |
+ """Takes a list of [cpv, [kws]] and prettifies it""" |
38 |
max_len = 0 |
39 |
- kws_all = [] |
40 |
- pretty_list = [] |
41 |
- cpv_block_size = 0 |
42 |
+ kws_all = set() |
43 |
|
44 |
- for each in cpv_kws: |
45 |
- # Ignore comments/whitespace carried over from original list |
46 |
- if type(each) is not list: |
47 |
- continue |
48 |
- # Find the atom with max length (for output formatting) |
49 |
- if len(each[0]) > max_len: |
50 |
- max_len = len(each[0]) |
51 |
- # Find the set of all kws listed |
52 |
- for kw in each[1]: |
53 |
- if kw not in kws_all: |
54 |
- kws_all.append(kw) |
55 |
- kws_all.sort() |
56 |
- |
57 |
- for each in cpv_kws: |
58 |
- # Handle comments/whitespace carried over from original list |
59 |
- if type(each) is not list: |
60 |
- # If the prev cpv block has just one line, don't print an extra \n |
61 |
- # XXX: This code relies on blocks of dep-cpvs being separated by \n |
62 |
- if CHECK_DEPS and cpv_block_size is 1: |
63 |
- cpv_block_size = 0 |
64 |
- continue |
65 |
- pretty_list.append([each, []]) |
66 |
- cpv_block_size = 0 |
67 |
- continue |
68 |
- # The size of the current cpv list block |
69 |
- cpv_block_size += 1 |
70 |
- # Pad the cpvs with space |
71 |
- each[0] += n_sep(max_len - len(each[0])) |
72 |
- for i in range(0, len(kws_all)): |
73 |
- if i == len(each[1]): |
74 |
- # Prevent an IndexError |
75 |
- # This is a problem in the algo I selected |
76 |
- each[1].append('') |
77 |
- if each[1][i] != kws_all[i]: |
78 |
- # If no arch, insert space |
79 |
- each[1].insert(i, n_sep(len(kws_all[i]))) |
80 |
- pretty_list.append([each[0], each[1]]) |
81 |
- return pretty_list |
82 |
+ for dep_set in cpv_kws: |
83 |
+ for cpv, kws in dep_set: |
84 |
+ # Find the atom with max length (for output formatting) |
85 |
+ max_len = max(max_len, len(cpv)) |
86 |
+ # Find the set of all kws listed |
87 |
+ kws_all.update(kws) |
88 |
+ |
89 |
+ for dep_set in cpv_kws: |
90 |
+ for cpv, kws in dep_set: |
91 |
+ pretty_line = cpv + ' ' * (max_len - len(cpv)) |
92 |
+ |
93 |
+ for kwd in sorted(kws_all): |
94 |
+ if kwd in kws: |
95 |
+ pretty_line += ' ' + kwd |
96 |
+ else: |
97 |
+ pretty_line += ' ' + ' ' * len(kwd) |
98 |
+ |
99 |
+ print(pretty_line) |
100 |
+ |
101 |
+ if len(dep_set) > 1: |
102 |
+ print() |
103 |
+ |
104 |
+ return |
105 |
|
106 |
|
107 |
##################### |
108 |
@@ -511,8 +493,7 @@ def main(): |
109 |
if args.append_slots: |
110 |
ALL_CPV_KWS = append_slots(ALL_CPV_KWS) |
111 |
|
112 |
- for i in prettify(ALL_CPV_KWS): |
113 |
- print i[0], flatten(i[1]) |
114 |
+ print_cpv_kws(ALL_CPV_KWS) |
115 |
|
116 |
|
117 |
if __name__ == '__main__': |