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: <1435356879.6d936200f6324e340e823b7925c910d3c340b226.eva@gentoo> (raw)

commit:     6d936200f6324e340e823b7925c910d3c340b226
Author:     Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 25 11:22:16 2015 +0000
Commit:     Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Fri Jun 26 22:14:39 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gnome.git/commit/?id=6d936200

scripts/gen_archlist: rewrite consolidates_dupes using sets

 scripts/gen_archlist.py | 63 ++++++++++++++-----------------------------------
 1 file changed, 18 insertions(+), 45 deletions(-)

diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
index 659c84e..d595df3 100755
--- a/scripts/gen_archlist.py
+++ b/scripts/gen_archlist.py
@@ -24,6 +24,7 @@
 from __future__ import division
 
 import argparse
+import collections
 import os
 import sys
 
@@ -41,7 +42,6 @@ UNSTABLE_ARCHES = ('~alpha', '~amd64', '~arm', '~hppa', '~ia64', '~m68k',
                    '~x86-fbsd')
 ALL_ARCHES = STABLE_ARCHES + UNSTABLE_ARCHES
 SYSTEM_PACKAGES = []
-LINE_SEP = ''
 
 ############
 # Settings #
@@ -348,52 +348,27 @@ def gen_cpv_kws(cpv, kws_aim, depgraph, check_dependencies, new_release):
 
 
 def consolidate_dupes(cpv_kws):
-    """
-    Consolidate duplicate cpvs with differing keywords
+    """Consolidate duplicate CPVs with differing keywords.
 
-    Cannot handle cps with different versions since we don't know if they are
-    inter-changeable
+    Cannot handle CPs with different versions since we don't know if they are
+    inter-changeable.
     """
-    cpv_indices = {}
-
-    # Find all indices of each cpv
-    for each in cpv_kws:
-        # Comments/whitespace carried over from original list
-        if type(each) is not list:
-            continue
-        else:
-            if each[0] not in cpv_indices:
-                cpv_indices[each[0]] = []
-            cpv_indices[each[0]].append(cpv_kws.index(each))
+    # Build maximum requested keywords for each cpv
+    cpv_kws_dict = collections.defaultdict(set)
+    for dep_set in cpv_kws:
+        for cpv, kws in dep_set:
+            cpv_kws_dict[cpv].update(kws)
 
-    # Replace the keywords of each cpv with the union of all keywords in the
-    # list belonging to this cpv
-    for each in cpv_kws:
-        # Ignore comments/whitespace carried over from original list
-        if type(each) is not list:
-            continue
-        kws = set()
-        for index in cpv_indices[each[0]]:
-            kws.update(cpv_kws[index][1])
-        each[1] = list(kws)
-        each[1].sort()
-
-    index = 0
-    deduped_cpv_kws = cpv_kws[:]
-    deduped_cpv_kws.reverse()
-    while index < len(deduped_cpv_kws):
-        item = deduped_cpv_kws[index]
-        if type(item) is not list:
-            index += 1
-            continue
-        if deduped_cpv_kws.count(item) is 1:
-            index += 1
-        else:
-            while deduped_cpv_kws.count(item) is not 1:
-                deduped_cpv_kws.remove(item)
-    deduped_cpv_kws.reverse()
+    # Update cpv with their maximum request keywords
+    clean_cpv_kws = []
+    for dep_set in cpv_kws:
+        clean_cpv_kws.append([
+            (cpv, cpv_kws_dict.pop(cpv))
+            # Keep only first occurence of cpv
+            for cpv, _ in dep_set if cpv in cpv_kws_dict
+        ])
 
-    return deduped_cpv_kws
+    return clean_cpv_kws
 
 
 def get_per_slot_cpvs(cpvs):
@@ -531,8 +506,6 @@ def main():
                 gen_cpv_kws(cpv, kws_missing, set([cpv]),
                             args.check_dependencies, args.new_version)
             )
-            if args.check_dependencies:
-                ALL_CPV_KWS.append(LINE_SEP)
 
     ALL_CPV_KWS = consolidate_dupes(ALL_CPV_KWS)
     if args.append_slots:


             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=1435356879.6d936200f6324e340e823b7925c910d3c340b226.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