Gentoo Archives: gentoo-commits

From: Sebastian Pipping <sping@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/ekeyword/
Date: Mon, 11 Sep 2017 20:20:29
Message-Id: 1504962267.0bbf21d7c25743e030879ab65af5e432aba2eaa3.sping@gentoo
1 commit: 0bbf21d7c25743e030879ab65af5e432aba2eaa3
2 Author: Sebastian Pipping <sebastian <AT> pipping <DOT> org>
3 AuthorDate: Sat Sep 9 13:04:27 2017 +0000
4 Commit: Sebastian Pipping <sping <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 9 13:04:27 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=0bbf21d7
7
8 ekeyword: Support sorting keywords without additional changes
9
10 pym/gentoolkit/ekeyword/ekeyword.py | 26 +++++++++++++++++++-------
11 1 file changed, 19 insertions(+), 7 deletions(-)
12
13 diff --git a/pym/gentoolkit/ekeyword/ekeyword.py b/pym/gentoolkit/ekeyword/ekeyword.py
14 index 170c25b..af37a9a 100755
15 --- a/pym/gentoolkit/ekeyword/ekeyword.py
16 +++ b/pym/gentoolkit/ekeyword/ekeyword.py
17 @@ -261,15 +261,29 @@ def process_content(ebuild, data, ops, arch_status=None, verbose=0,
18 continue
19
20 # Ok, we've got it, now let's process things.
21 - old_keywords = set(m.group(3).split())
22 + old_keywords_original = m.group(3).split() # preserve original order
23 + old_keywords = set(old_keywords_original)
24 new_keywords = process_keywords(
25 old_keywords, ops, arch_status=arch_status)
26
27 + were_sorted_already = (
28 + old_keywords_original == sort_keywords(old_keywords_original))
29 +
30 # Finally let's present the results to the user.
31 - if (new_keywords != old_keywords) or verbose:
32 + if (new_keywords != old_keywords) or \
33 + (not ops and not were_sorted_already) or verbose:
34 # Only do the diff work if something actually changed.
35 updated = True
36 - old_keywords = sort_keywords(old_keywords)
37 +
38 + if not ops:
39 + # We're sorting only so we want to compare with the
40 + # unsorted original (or changes in order will not show)
41 + old_keywords = old_keywords_original
42 + else:
43 + # We changed keywords so let's diff sorted versions
44 + # so that keywords changes are easy to spot
45 + old_keywords = sort_keywords(old_keywords)
46 +
47 new_keywords = sort_keywords(new_keywords)
48 line = '%s"%s"%s\n' % (m.group(1), ' '.join(new_keywords),
49 m.group(5))
50 @@ -435,14 +449,12 @@ def args_to_work(args, arch_status=None, _repo='gentoo', quiet=0):
51 """Process |args| into a list of work itmes (ebuild/arches to update)"""
52 work = []
53 todo_arches = []
54 - last_todo_arches = None
55 + last_todo_arches = []
56
57 for arg in args:
58 if arg.endswith('.ebuild'):
59 if not todo_arches:
60 todo_arches = last_todo_arches
61 - if not todo_arches:
62 - raise ValueError('missing arches to process for %s' % arg)
63 work.append([arg, todo_arches])
64 last_todo_arches = todo_arches
65 todo_arches = []
66 @@ -510,7 +522,7 @@ def main(argv):
67 parser = get_parser()
68 opts = parser.parse_args(parse_args)
69 if not work_args:
70 - parser.error('need arches/ebuilds to process')
71 + parser.error('need ebuilds to process')
72
73 if opts.style == 'auto':
74 if not portage_settings().get('NOCOLOR', 'false').lower() in ('no', 'false'):