1 |
commit: 97595e02fc8eced9a1a54d246a4163fae6badcaf |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jan 23 12:30:02 2018 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jan 26 14:50:50 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=97595e02 |
7 |
|
8 |
eshowkw: Sort pure ~arch arches after stable keyword arches |
9 |
|
10 |
To match the new ordering on Bugzilla, order arches with pure ~arch |
11 |
keywords after those having stable keywords. The idea behind it is to |
12 |
make it easier to determine which arches to CC on stablereqs. |
13 |
|
14 |
The pure ~arch arch list is hardcoded for now to mips + *-* (fbsd, |
15 |
prefix). However, in the future it will be replaced by status defined |
16 |
by arches.desc once that GLEP is finalized. |
17 |
|
18 |
pym/gentoolkit/eshowkw/keywords_header.py | 31 +++++++++++++++++++++++++------ |
19 |
1 file changed, 25 insertions(+), 6 deletions(-) |
20 |
|
21 |
diff --git a/pym/gentoolkit/eshowkw/keywords_header.py b/pym/gentoolkit/eshowkw/keywords_header.py |
22 |
index 1a1a422..c9f2381 100644 |
23 |
--- a/pym/gentoolkit/eshowkw/keywords_header.py |
24 |
+++ b/pym/gentoolkit/eshowkw/keywords_header.py |
25 |
@@ -15,7 +15,7 @@ from portage.output import colorize |
26 |
from gentoolkit.eshowkw.display_pretty import colorize_string |
27 |
from gentoolkit.eshowkw.display_pretty import align_string |
28 |
|
29 |
-# Copied from ekeyword |
30 |
+# Copied from ekeyword, modified to support arch vs ~arch status |
31 |
def load_profile_data(portdir=None, repo='gentoo'): |
32 |
"""Load the list of known arches from the tree |
33 |
|
34 |
@@ -25,7 +25,7 @@ def load_profile_data(portdir=None, repo='gentoo'): |
35 |
|
36 |
Returns: |
37 |
A dict mapping the keyword to its preferred state: |
38 |
- {'x86': 'stable', 'mips': 'dev', ...} |
39 |
+ {'x86': ('stable', 'arch'), 'mips': ('dev', '~arch'), ...} |
40 |
""" |
41 |
if portdir is None: |
42 |
portdir = portage.db[portage.root]['vartree'].settings.repositories[repo].location |
43 |
@@ -71,16 +71,28 @@ def load_profile_data(portdir=None, repo='gentoo'): |
44 |
warning('could not read profile files: %s' % arch_list) |
45 |
warning('will not be able to verify args are correct') |
46 |
|
47 |
+ # TODO: support arches.desc once the GLEP is finalized |
48 |
+ # for now, we just hardcode ~mips + *-* (fbsd, prefix) |
49 |
+ for k, v in arch_status.items(): |
50 |
+ if k == 'mips' or '-' in k: |
51 |
+ arch_status[k] = (v, '~arch') |
52 |
+ else: |
53 |
+ arch_status[k] = (v, 'arch') |
54 |
+ |
55 |
return arch_status |
56 |
|
57 |
def gen_arch_list(status): |
58 |
_arch_status = load_profile_data() |
59 |
if status == "stable": |
60 |
- return [arch for arch in _arch_status if _arch_status[arch] == "stable"] |
61 |
+ return [arch for arch in _arch_status if _arch_status[arch][0] == "stable"] |
62 |
elif status == "dev": |
63 |
- return [arch for arch in _arch_status if _arch_status[arch] == "dev"] |
64 |
+ return [arch for arch in _arch_status if _arch_status[arch][0] == "dev"] |
65 |
elif status == "exp": |
66 |
- return [arch for arch in _arch_status if _arch_status[arch] == "exp"] |
67 |
+ return [arch for arch in _arch_status if _arch_status[arch][0] == "exp"] |
68 |
+ elif status == "arch": |
69 |
+ return [arch for arch in _arch_status if _arch_status[arch][1] == "arch"] |
70 |
+ elif status == "~arch": |
71 |
+ return [arch for arch in _arch_status if _arch_status[arch][1] == "~arch"] |
72 |
else: |
73 |
raise TypeError |
74 |
|
75 |
@@ -88,6 +100,7 @@ class keywords_header: |
76 |
__IMPARCHS = gen_arch_list("stable") |
77 |
__DEV_ARCHS = gen_arch_list("dev") |
78 |
__EXP_ARCHS = gen_arch_list("exp") |
79 |
+ __TESTING_KW_ARCHS = gen_arch_list("~arch") |
80 |
__ADDITIONAL_FIELDS = [ 'eapi', 'unused', 'slot' ] |
81 |
__EXTRA_FIELDS = [ 'repo' ] |
82 |
|
83 |
@@ -128,7 +141,13 @@ class keywords_header: |
84 |
levels[kw] = level |
85 |
break |
86 |
|
87 |
- normal.sort(key=lambda kw: (levels.get(kw, 99), kw.count('-'), kw)) |
88 |
+ # sort by, in order (to match Bugzilla): |
89 |
+ # 1. arch, then ~arch |
90 |
+ # 2. profile stability |
91 |
+ # 3. short keywords, then long (prefix, fbsd) |
92 |
+ # 4. keyword name |
93 |
+ normal.sort(key=lambda kw: (kw in self.__TESTING_KW_ARCHS, |
94 |
+ levels.get(kw, 99), kw.count('-'), kw)) |
95 |
return normal |
96 |
|
97 |
def __readAdditionalFields(self): |