1 |
commit: 24bd1b67e381e6aa5bff5e597bd3a96c98f4f4a7 |
2 |
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 25 07:57:48 2015 +0000 |
4 |
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jun 25 12:46:23 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=24bd1b67 |
7 |
|
8 |
scripts/gen_archlist: use sets for manipulating keywords |
9 |
|
10 |
Avoids logic like "if bla not in list then add it" when it is done by |
11 |
sets already. Sorting can be applied when printing. |
12 |
|
13 |
scripts/gen_archlist.py | 27 +++++++++++++-------------- |
14 |
1 file changed, 13 insertions(+), 14 deletions(-) |
15 |
|
16 |
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py |
17 |
index 6e00ec1..f2a68e5 100755 |
18 |
--- a/scripts/gen_archlist.py |
19 |
+++ b/scripts/gen_archlist.py |
20 |
@@ -101,10 +101,10 @@ def nothing_to_be_done(atom, type='cpv'): |
21 |
|
22 |
def make_unstable(kws): |
23 |
"""Transform `kws` into a list of unstable keywords.""" |
24 |
- return [ |
25 |
+ return set([ |
26 |
kwd if kwd.startswith('~') else '~' + kwd |
27 |
for kwd in kws |
28 |
- ] |
29 |
+ ]) |
30 |
|
31 |
|
32 |
def belongs_release(cpv, release): |
33 |
@@ -124,10 +124,10 @@ def issystempackage(cpv): |
34 |
|
35 |
def get_kws(cpv, arches=ARCHES): |
36 |
"""Return keywords of `cpv` filtered by `arches`.""" |
37 |
- return [ |
38 |
+ return set([ |
39 |
kwd for kwd in portage.portdb.aux_get(cpv, ['KEYWORDS'])[0].split() |
40 |
if kwd in arches |
41 |
- ] |
42 |
+ ]) |
43 |
|
44 |
|
45 |
def can_stabilize_cpv(cpv, release=None): |
46 |
@@ -188,14 +188,14 @@ def get_best_deps(cpv, kws, release=None): |
47 |
if STABLE: |
48 |
# Check that this version has unstable keywords |
49 |
ukws = make_unstable(kws) |
50 |
- cur_ukws = set(make_unstable(get_kws(i, arches=kws+ukws))) |
51 |
- if cur_ukws.intersection(ukws) != set(ukws): |
52 |
+ cur_ukws = make_unstable(get_kws(i, arches=kws | ukws)) |
53 |
+ if cur_ukws.intersection(ukws) != ukws: |
54 |
best_kws = 'none' |
55 |
if DEBUG: |
56 |
debug('Insufficient unstable keywords in: %s' % i) |
57 |
continue |
58 |
cur_match_kws = get_kws(i, arches=kws) |
59 |
- if set(cur_match_kws) == set(kws): |
60 |
+ if cur_match_kws == kws: |
61 |
# This dep already has all keywords |
62 |
best_kws = 'alreadythere' |
63 |
break |
64 |
@@ -279,7 +279,7 @@ def max_kws(cpv, release=None): |
65 |
missing_kws.add(kwd) |
66 |
|
67 |
if maximum_kws: |
68 |
- return sorted(missing_kws) |
69 |
+ return missing_kws |
70 |
else: |
71 |
# No cpv has the keywords we need |
72 |
return None |
73 |
@@ -288,13 +288,12 @@ def max_kws(cpv, release=None): |
74 |
# FIXME: This is broken |
75 |
def kws_wanted(current_kws, target_kws): |
76 |
"""Generate a list of kws that need to be updated.""" |
77 |
- wanted = [] |
78 |
+ wanted = set() |
79 |
for kwd in target_kws: |
80 |
- if kwd not in current_kws: |
81 |
- if STABLE and '~' + kwd not in current_kws: |
82 |
- # Skip stable keywords with no corresponding unstable keyword |
83 |
- continue |
84 |
- wanted.append(kwd) |
85 |
+ if STABLE and '~' + kwd not in current_kws: |
86 |
+ # Skip stable keywords with no corresponding unstable keyword |
87 |
+ continue |
88 |
+ wanted.add(kwd) |
89 |
return wanted |