aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2020-04-24 09:55:49 +0200
committerMichał Górny <mgorny@gentoo.org>2020-04-24 09:56:24 +0200
commit459cfba47d2522553d076ebaabf656ce8f29cf11 (patch)
tree0f946ee2f2c4398c9bb90908f2c82181c80d8ec0
parentDisable testing on py27 (diff)
downloadgentoolkit-459cfba47d2522553d076ebaabf656ce8f29cf11.tar.gz
gentoolkit-459cfba47d2522553d076ebaabf656ce8f29cf11.tar.bz2
gentoolkit-459cfba47d2522553d076ebaabf656ce8f29cf11.zip
ekeyword: Use now-common load_profile_data() from eshowkw
This also fixes 'all' to process all architectures using stable keywords and not just these having stable profiles. Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rwxr-xr-xpym/gentoolkit/ekeyword/ekeyword.py62
-rwxr-xr-xpym/gentoolkit/ekeyword/ekeyword_unittest.py36
2 files changed, 3 insertions, 95 deletions
diff --git a/pym/gentoolkit/ekeyword/ekeyword.py b/pym/gentoolkit/ekeyword/ekeyword.py
index cf2a15e..a86a9c2 100755
--- a/pym/gentoolkit/ekeyword/ekeyword.py
+++ b/pym/gentoolkit/ekeyword/ekeyword.py
@@ -47,6 +47,8 @@ import re
import subprocess
import sys
+from gentoolkit.profile import load_profile_data
+
import portage
from portage.output import colorize, nocolor
@@ -179,7 +181,7 @@ def process_keywords(keywords, ops, arch_status=None):
if op is None:
# Process just stable keywords.
arches = [k for k, v in arch_status.items()
- if v == 'stable' and k in old_arches]
+ if v[1] == 'arch' and k in old_arches]
else:
# Process all possible keywords. We use the arch_status as a
# master list. If it lacks some keywords, then we might miss
@@ -346,64 +348,6 @@ def portage_settings():
return portage.db[portage.root]['vartree'].settings
-def load_profile_data(portdir=None, repo=None):
- """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 repo is None:
- repo = portage_settings().repositories.mainRepo().name
- if portdir is None:
- portdir = portage_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 arg_to_op(arg):
"""Convert a command line |arg| to an Op"""
arch_prefixes = ('-', '~', '^')
diff --git a/pym/gentoolkit/ekeyword/ekeyword_unittest.py b/pym/gentoolkit/ekeyword/ekeyword_unittest.py
index 5e66afe..7446914 100755
--- a/pym/gentoolkit/ekeyword/ekeyword_unittest.py
+++ b/pym/gentoolkit/ekeyword/ekeyword_unittest.py
@@ -343,42 +343,6 @@ class TestProcessEbuild(unittest.TestCase):
self.assertEqual(m.call_count, 0)
-class TestLoadProfileData(unittest.TestCase):
- """Tests for load_profile_data"""
-
- def _test(self, subdir):
- portdir = os.path.join(TESTDIR, 'profiles', subdir)
- return ekeyword.load_profile_data(portdir=portdir)
-
- def testLoadBoth(self):
- """Test loading both arch.list and profiles.desc"""
- ret = self._test('both')
- self.assertIn('arm', ret)
- self.assertEqual(ret['arm'], 'stable')
- self.assertIn('arm64', ret)
- self.assertEqual(ret['arm64'], 'exp')
-
- def testLoadArchOnly(self):
- """Test loading only arch.list"""
- ret = self._test('arch-only')
- self.assertIn('arm', ret)
- self.assertEqual(ret['arm'], None)
- self.assertIn('x86-solaris', ret)
-
- def testLoadProfilesOnly(self):
- """Test loading only profiles.desc"""
- ret = self._test('profiles-only')
- self.assertIn('arm', ret)
- self.assertEqual(ret['arm'], 'stable')
- self.assertIn('arm64', ret)
- self.assertEqual(ret['arm64'], 'exp')
-
- def testLoadNone(self):
- """Test running when neither files exists"""
- ret = self._test('none')
- self.assertEqual(ret, {})
-
-
class TestArgToOps(unittest.TestCase):
"""Tests for arg_to_op()"""