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 5461C138D02 for ; Fri, 26 Jun 2015 22:32:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 27D2AE0856; Fri, 26 Jun 2015 22:32:09 +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 11E33E0843 for ; Fri, 26 Jun 2015 22:32:07 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1FD8A340A31 for ; Fri, 26 Jun 2015 22:32:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 92983736 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: <1435236383.24bd1b67e381e6aa5bff5e597bd3a96c98f4f4a7.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: 24bd1b67e381e6aa5bff5e597bd3a96c98f4f4a7 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: 6a9ce42b-abdd-4a55-8fb7-4a060d14b90a X-Archives-Hash: 43aec3132df9b598a12af6709f30429c commit: 24bd1b67e381e6aa5bff5e597bd3a96c98f4f4a7 Author: Gilles Dartiguelongue gentoo org> AuthorDate: Thu Jun 25 07:57:48 2015 +0000 Commit: Gilles Dartiguelongue gentoo org> CommitDate: Thu Jun 25 12:46:23 2015 +0000 URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=24bd1b67 scripts/gen_archlist: use sets for manipulating keywords Avoids logic like "if bla not in list then add it" when it is done by sets already. Sorting can be applied when printing. scripts/gen_archlist.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py index 6e00ec1..f2a68e5 100755 --- a/scripts/gen_archlist.py +++ b/scripts/gen_archlist.py @@ -101,10 +101,10 @@ def nothing_to_be_done(atom, type='cpv'): def make_unstable(kws): """Transform `kws` into a list of unstable keywords.""" - return [ + return set([ kwd if kwd.startswith('~') else '~' + kwd for kwd in kws - ] + ]) def belongs_release(cpv, release): @@ -124,10 +124,10 @@ def issystempackage(cpv): def get_kws(cpv, arches=ARCHES): """Return keywords of `cpv` filtered by `arches`.""" - return [ + return set([ kwd for kwd in portage.portdb.aux_get(cpv, ['KEYWORDS'])[0].split() if kwd in arches - ] + ]) def can_stabilize_cpv(cpv, release=None): @@ -188,14 +188,14 @@ def get_best_deps(cpv, kws, release=None): if STABLE: # Check that this version has unstable keywords ukws = make_unstable(kws) - cur_ukws = set(make_unstable(get_kws(i, arches=kws+ukws))) - if cur_ukws.intersection(ukws) != set(ukws): + cur_ukws = make_unstable(get_kws(i, arches=kws | ukws)) + if cur_ukws.intersection(ukws) != ukws: best_kws = 'none' if DEBUG: debug('Insufficient unstable keywords in: %s' % i) continue cur_match_kws = get_kws(i, arches=kws) - if set(cur_match_kws) == set(kws): + if cur_match_kws == kws: # This dep already has all keywords best_kws = 'alreadythere' break @@ -279,7 +279,7 @@ def max_kws(cpv, release=None): missing_kws.add(kwd) if maximum_kws: - return sorted(missing_kws) + return missing_kws else: # No cpv has the keywords we need return None @@ -288,13 +288,12 @@ def max_kws(cpv, release=None): # FIXME: This is broken def kws_wanted(current_kws, target_kws): """Generate a list of kws that need to be updated.""" - wanted = [] + wanted = set() for kwd in target_kws: - if kwd not in current_kws: - if STABLE and '~' + kwd not in current_kws: - # Skip stable keywords with no corresponding unstable keyword - continue - wanted.append(kwd) + if STABLE and '~' + kwd not in current_kws: + # Skip stable keywords with no corresponding unstable keyword + continue + wanted.add(kwd) return wanted