From: "Justin Lecher" <jlec@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eshowkw/
Date: Thu, 19 Nov 2015 11:59:16 +0000 (UTC) [thread overview]
Message-ID: <1447934192.239b0c9b6ea62189f6ce69f72a291a4f8c9fa463.jlec@gentoo> (raw)
commit: 239b0c9b6ea62189f6ce69f72a291a4f8c9fa463
Author: Justin Lecher <jlec <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 19 11:56:32 2015 +0000
Commit: Justin Lecher <jlec <AT> gentoo <DOT> org>
CommitDate: Thu Nov 19 11:56:32 2015 +0000
URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=239b0c9b
Get status of arch from profile
The stable, dev, exp status of the arches was hardcoded.
This change copies the code form ekeyword to read the status from profiles
directly.
Signed-off-by: Justin Lecher <jlec <AT> gentoo.org>
| 76 +++++++++++++++++++++++++++++--
1 file changed, 73 insertions(+), 3 deletions(-)
--git a/pym/gentoolkit/eshowkw/keywords_header.py b/pym/gentoolkit/eshowkw/keywords_header.py
index 320406e..aaf1e8c 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -4,14 +4,84 @@
__all__ = ['keywords_header']
+import portage
+import os
from portage import settings as ports
from portage.output import colorize
from gentoolkit.eshowkw.display_pretty import colorize_string
from gentoolkit.eshowkw.display_pretty import align_string
+# Copied from ekeyword
+def load_profile_data(portdir=None, repo='gentoo'):
+ """Load the list of known arches from the tree
+
+ Args:
+ portdir: The repository to load all data from (and ignore |repo|)
+ repo: Look up this repository by name to locate profile data
+
+ Returns:
+ A dict mapping the keyword to its preferred state:
+ {'x86': 'stable', 'mips': 'dev', ...}
+ """
+ if portdir is None:
+ portdir = portage.db['/']['vartree'].settings.repositories[repo].location
+
+ arch_status = {}
+
+ try:
+ arch_list = os.path.join(portdir, 'profiles', 'arch.list')
+ with open(arch_list) as f:
+ for line in f:
+ line = line.split('#', 1)[0].strip()
+ if line:
+ arch_status[line] = None
+ except IOError:
+ pass
+
+ try:
+ profile_status = {
+ 'stable': 0,
+ 'dev': 1,
+ 'exp': 2,
+ None: 3,
+ }
+ profiles_list = os.path.join(portdir, 'profiles', 'profiles.desc')
+ with open(profiles_list) as f:
+ for line in f:
+ line = line.split('#', 1)[0].split()
+ if line:
+ arch, _profile, status = line
+ arch_status.setdefault(arch, status)
+ curr_status = profile_status[arch_status[arch]]
+ new_status = profile_status[status]
+ if new_status < curr_status:
+ arch_status[arch] = status
+ except IOError:
+ pass
+
+ if arch_status:
+ arch_status['all'] = None
+ else:
+ warning('could not read profile files: %s' % arch_list)
+ warning('will not be able to verify args are correct')
+
+ return arch_status
+
+def gen_arch_list(status):
+ _arch_status = load_profile_data()
+ if status == "stable":
+ return [arch for arch in _arch_status if _arch_status[arch] == "stable"]
+ elif status == "dev":
+ return [arch for arch in _arch_status if _arch_status[arch] == "dev"]
+ elif status == "exp":
+ return [arch for arch in _arch_status if _arch_status[arch] == "exp"]
+ else:
+ raise TypeError
+
class keywords_header:
- __IMPARCHS = [ 'arm', 'amd64', 'x86' ]
- __UNSTABLE_ARCHS = [ 'arm64', 'm68k', 'mips', 's390', 'sh' ]
+ __IMPARCHS = gen_arch_list("stable")
+ __DEV_ARCHS = gen_arch_list("dev")
+ __EXP_ARCHS = gen_arch_list("exp")
__ADDITIONAL_FIELDS = [ 'eapi', 'unused', 'slot' ]
__EXTRA_FIELDS = [ 'repo' ]
@@ -61,7 +131,7 @@ class keywords_header:
keyword = '%'.join(list(keyword))
if tmp2 in self.__IMPARCHS:
tmp.append(colorize_string('darkyellow', keyword))
- elif tmp2 in self.__UNSTABLE_ARCHS:
+ elif tmp2 in self.__EXP_ARCHS:
tmp.append(colorize_string('darkgray', keyword))
else:
tmp.append(keyword)
next reply other threads:[~2015-11-19 11:59 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-19 11:59 Justin Lecher [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-07-09 1:49 [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eshowkw/ Mike Gilbert
2022-06-08 20:11 Brian Dolbec
2022-06-08 1:19 Brian Dolbec
2022-06-08 0:12 Brian Dolbec
2020-01-26 15:20 Michał Górny
2019-05-11 20:26 Michał Górny
2018-01-26 23:25 Michał Górny
2018-01-26 23:25 Michał Górny
2018-01-26 23:25 Michał Górny
2018-01-26 23:25 Michał Górny
2018-01-26 23:25 Michał Górny
2018-01-26 23:25 Michał Górny
2018-01-26 23:25 Michał Górny
2018-01-26 23:25 Michał Górny
2016-11-23 23:26 Zac Medico
2016-07-03 17:59 Zac Medico
2016-07-03 17:53 Zac Medico
2016-07-03 4:23 Zac Medico
2016-04-06 17:25 Paul Varner
2016-03-31 22:10 Paul Varner
2016-03-17 21:39 Dirkjan Ochtman
2015-11-17 10:19 Justin Lecher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447934192.239b0c9b6ea62189f6ce69f72a291a4f8c9fa463.jlec@gentoo \
--to=jlec@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox