Gentoo Archives: gentoo-commits

From: Gilles Dartiguelongue <eva@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/
Date: Fri, 26 Jun 2015 22:32:33
Message-Id: 1435236365.3dd724f0698988b69d2c15aa502d181ca609943b.eva@gentoo
1 commit: 3dd724f0698988b69d2c15aa502d181ca609943b
2 Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jun 24 12:07:21 2015 +0000
4 Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
5 CommitDate: Thu Jun 25 12:46:05 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=3dd724f0
7
8 scripts/gen_archlist: simplify functions and try to enhance documentation
9
10 scripts/gen_archlist.py | 60 ++++++++++++++++++++++---------------------------
11 1 file changed, 27 insertions(+), 33 deletions(-)
12
13 diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py
14 index b21fba2..3ac9f88 100755
15 --- a/scripts/gen_archlist.py
16 +++ b/scripts/gen_archlist.py
17 @@ -101,14 +101,11 @@ def nothing_to_be_done(atom, type='cpv'):
18
19
20 def make_unstable(kws):
21 - "Takes a keyword list, and returns a list with them all unstable"
22 - nkws = []
23 - for kw in kws:
24 - if not kw.startswith('~'):
25 - nkws.append('~'+kw)
26 - else:
27 - nkws.append(kw)
28 - return nkws
29 + """Transform `kws` into a list of unstable keywords."""
30 + return [
31 + kwd if kwd.startswith('~') else '~' + kwd
32 + for kwd in kws
33 + ]
34
35
36 def belongs_release(cpv, release):
37 @@ -127,14 +124,11 @@ def issystempackage(cpv):
38
39
40 def get_kws(cpv, arches=ARCHES):
41 - """
42 - Returns an array of KEYWORDS matching 'arches'
43 - """
44 - kws = []
45 - for kw in portage.portdb.aux_get(cpv, ['KEYWORDS'])[0].split():
46 - if kw in arches:
47 - kws.append(kw)
48 - return kws
49 + """Return keywords of `cpv` filtered by `arches`."""
50 + return [
51 + kwd for kwd in portage.portdb.aux_get(cpv, ['KEYWORDS'])[0].split()
52 + if kwd in arches
53 + ]
54
55
56 def do_not_want(cpv, release=None):
57 @@ -149,20 +143,20 @@ def do_not_want(cpv, release=None):
58
59
60 def match_wanted_atoms(atom, release=None):
61 + """Return a list of CPV matching `atom`.
62 +
63 + If `release` is provided, CPVs are filtered against it.
64 +
65 + The list is sorted by descending order of version.
66 """
67 - Given an atom and a release, return all matching wanted atoms ordered in
68 - descending order of version
69 - """
70 - atoms = []
71 # xmatch is stupid, and ignores ! in an atom...
72 if atom.startswith('!'):
73 return []
74 - for cpv in portage.portdb.xmatch('match-all', atom):
75 - if do_not_want(cpv, release):
76 - continue
77 - atoms.append(cpv)
78 - atoms.reverse()
79 - return atoms
80 +
81 + return [
82 + cpv for cpv in reversed(portage.portdb.xmatch('match-all', atom))
83 + if not do_not_want(cpv, release)
84 + ]
85
86
87 def get_best_deps(cpv, kws, release=None):
88 @@ -278,15 +272,15 @@ def max_kws(cpv, release=None):
89
90
91 # FIXME: This is broken
92 -def kws_wanted(cpv_kws, prev_cpv_kws):
93 - "Generate a list of kws that need to be updated"
94 +def kws_wanted(current_kws, target_kws):
95 + """Generate a list of kws that need to be updated."""
96 wanted = []
97 - for kw in prev_cpv_kws:
98 - if kw not in cpv_kws:
99 - if STABLE and '~'+kw not in cpv_kws:
100 - # Ignore if no keywords at all
101 + for kwd in target_kws:
102 + if kwd not in current_kws:
103 + if STABLE and '~' + kwd not in current_kws:
104 + # Skip stable keywords with no corresponding unstable keyword
105 continue
106 - wanted.append(kw)
107 + wanted.append(kwd)
108 return wanted