public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Gilles Dartiguelongue" <eva@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
Date: Fri, 26 Jun 2015 22:32:03 +0000 (UTC)	[thread overview]
Message-ID: <1435356880.19c52766c8ca16879f8b03b3f6a9b85c0865a04f.eva@gentoo> (raw)

commit:     19c52766c8ca16879f8b03b3f6a9b85c0865a04f
Author:     Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 25 12:47:22 2015 +0000
Commit:     Gilles Dartiguelongue <eva <AT> gentoo <DOT> 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__':


             reply	other threads:[~2015-06-26 22:32 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26 22:32 Gilles Dartiguelongue [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-09-06 16:53 [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/ Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-26 22:32 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue
2015-06-24 12:14 Gilles Dartiguelongue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435356880.19c52766c8ca16879f8b03b3f6a9b85c0865a04f.eva@gentoo \
    --to=eva@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox