summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/dep/__init__.py10
-rw-r--r--pym/portage/dep/dep_check.py7
-rw-r--r--pym/portage/package/ebuild/config.py8
-rw-r--r--pym/portage/tests/dep/testStandalone.py14
-rw-r--r--pym/portage/tests/dep/test_use_reduce.py80
5 files changed, 92 insertions, 27 deletions
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 9e4242edf..82c0c4e71 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -221,7 +221,7 @@ def paren_enclose(mylist):
return " ".join(mystrparts)
def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], is_src_uri=False, \
- allow_src_uri_file_renames=False):
+ allow_src_uri_file_renames=False, opconvert=False):
"""
Takes a dep string and reduces the use? conditionals out, leaving an array
with subarrays. All redundant brackets are removed.
@@ -313,7 +313,11 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
stack[level].pop()
stack[level].extend(l)
else:
- stack[level].append(l)
+ if opconvert and stack[level] and stack[level][-1] == "||":
+ stack[level].pop()
+ stack[level].append(["||"] + l)
+ else:
+ stack[level].append(l)
else:
raise portage.exception.InvalidDependString(
_("malformed syntax: '%s'") % depstr)
@@ -372,6 +376,8 @@ def dep_opconvert(deplist):
@return:
The new list with the new ordering
"""
+ warnings.warn(_("%s is deprecated. Use %s with the opconvert parameter set to True instead.") % \
+ ('portage.dep.dep_opconvert', 'portage.dep.use_reduce'), DeprecationWarning, stacklevel=2)
retlist = []
x = 0
diff --git a/pym/portage/dep/dep_check.py b/pym/portage/dep/dep_check.py
index 28d5771a7..74e14882b 100644
--- a/pym/portage/dep/dep_check.py
+++ b/pym/portage/dep/dep_check.py
@@ -6,7 +6,7 @@ __all__ = ['dep_check', 'dep_eval', 'dep_wordreduce', 'dep_zapdeps']
import logging
import portage
-from portage.dep import Atom, dep_opconvert, match_from_list, \
+from portage.dep import Atom, match_from_list, \
remove_slot, use_reduce
from portage.eapi import eapi_has_strong_blocks, eapi_has_use_deps, eapi_has_slot_deps, \
eapi_has_use_dep_defaults
@@ -543,13 +543,10 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
useforce.difference_update(mymasks)
try:
mysplit = use_reduce(depstring, uselist=myusesplit,
- masklist=mymasks, matchall=(use=="all"), excludeall=useforce)
+ masklist=mymasks, matchall=(use=="all"), excludeall=useforce, opconvert=True)
except InvalidDependString as e:
return [0, str(e)]
- # Do the || conversions
- mysplit = dep_opconvert(mysplit)
-
if mysplit == []:
#dependencies were reduced to nothing
return [1,[]]
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index 3b8ee10b5..495e3d1b8 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -31,7 +31,7 @@ from portage.const import CACHE_PATH, CUSTOM_PROFILE_PATH, \
from portage.dbapi import dbapi
from portage.dbapi.porttree import portdbapi
from portage.dbapi.vartree import vartree
-from portage.dep import Atom, best_match_to_list, dep_opconvert, \
+from portage.dep import Atom, best_match_to_list, \
flatten, isvalidatom, match_from_list, match_to_list, \
remove_slot, use_reduce
from portage.eapi import eapi_exports_AA, eapi_supports_prefix, eapi_exports_replace_vars
@@ -1926,8 +1926,7 @@ class config(object):
else:
use = []
- license_struct = use_reduce(license_str, uselist=use)
- license_struct = dep_opconvert(license_struct)
+ license_struct = use_reduce(license_str, uselist=use, opconvert=True)
return self._getMaskedLicenses(license_struct, acceptable_licenses)
def _getMaskedLicenses(self, license_struct, acceptable_licenses):
@@ -2016,8 +2015,7 @@ class config(object):
else:
use = []
- properties_struct = use_reduce(properties_str, uselist=use)
- properties_struct = dep_opconvert(properties_struct)
+ properties_struct = use_reduce(properties_str, uselist=use, opconvert=True)
return self._getMaskedProperties(properties_struct, acceptable_properties)
def _getMaskedProperties(self, properties_struct, acceptable_properties):
diff --git a/pym/portage/tests/dep/testStandalone.py b/pym/portage/tests/dep/testStandalone.py
index f018902e5..a5d661cc3 100644
--- a/pym/portage/tests/dep/testStandalone.py
+++ b/pym/portage/tests/dep/testStandalone.py
@@ -2,7 +2,7 @@
# Distributed under the terms of the GNU General Public License v2
from portage.tests import TestCase
-from portage.dep import cpvequal, dep_opconvert, flatten
+from portage.dep import cpvequal, flatten
from portage.exception import PortageException
class TestStandalone(TestCase):
@@ -48,15 +48,3 @@ class TestStandalone(TestCase):
for not_flat, flat in test_cases:
self.assertEqual(flatten(not_flat), flat)
-
- def testDep_opconvert(self):
-
- test_cases = (
- ( [], [] ),
- ( ["blah", "||", ["foo", "bar", "baz"]], ["blah", ["||", "foo", "bar", "baz"]] ),
- ( [["a", "b"], "||", ["c", "d", "e"]], [["a", "b"], ["||", "c", "d", "e"]] ),
- ( ["||", ["a", "b"], "||", ["c", "d", "e"]], [["||", "a", "b"], ["||", "c", "d", "e"]] ),
- )
-
- for orig, expected in test_cases:
- self.assertEqual(dep_opconvert(orig), expected)
diff --git a/pym/portage/tests/dep/test_use_reduce.py b/pym/portage/tests/dep/test_use_reduce.py
index ed77c40a3..e952e93d0 100644
--- a/pym/portage/tests/dep/test_use_reduce.py
+++ b/pym/portage/tests/dep/test_use_reduce.py
@@ -8,7 +8,7 @@ from portage.dep import use_reduce
class UseReduceTestCase(object):
def __init__(self, deparray, uselist=[], masklist=[], \
matchall=0, excludeall=[], is_src_uri=False, \
- allow_src_uri_file_renames=False, expected_result=None):
+ allow_src_uri_file_renames=False, opconvert=False, expected_result=None):
self.deparray = deparray
self.uselist = uselist
self.masklist = masklist
@@ -16,11 +16,12 @@ class UseReduceTestCase(object):
self.excludeall = excludeall
self.is_src_uri = is_src_uri
self.allow_src_uri_file_renames = allow_src_uri_file_renames
+ self.opconvert = opconvert
self.expected_result = expected_result
def run(self):
return use_reduce(self.deparray, self.uselist, self.masklist, \
- self.matchall, self.excludeall, self.is_src_uri, self.allow_src_uri_file_renames)
+ self.matchall, self.excludeall, self.is_src_uri, self.allow_src_uri_file_renames, self.opconvert)
class UseReduce(TestCase):
@@ -242,6 +243,81 @@ class UseReduce(TestCase):
is_src_uri = True,
allow_src_uri_file_renames = True,
expected_result = ["http://foo.com/foo", "http://foo/bar", "->", "blah.tbz2"]),
+
+ #opconvert tests
+ UseReduceTestCase(
+ "A",
+ opconvert = True,
+ expected_result = ["A"]),
+ UseReduceTestCase(
+ "( A )",
+ opconvert = True,
+ expected_result = ["A"]),
+ UseReduceTestCase(
+ "|| ( A B )",
+ opconvert = True,
+ expected_result = [ ["||", "A", "B"] ]),
+ UseReduceTestCase(
+ "|| ( A || ( B C ) )",
+ opconvert = True,
+ expected_result = [ ["||", "A", ["||", "B", "C"]] ]),
+ UseReduceTestCase(
+ "|| ( A || ( B C D ) )",
+ opconvert = True,
+ expected_result = [ ["||", "A", ["||", "B", "C", "D"]] ]),
+ UseReduceTestCase(
+ "|| ( A || ( B || ( C D ) E ) )",
+ expected_result = [ "||", ["A", "||", ["B", "||", ["C", "D"], "E"]] ]),
+ UseReduceTestCase(
+ "( || ( ( ( A ) B ) ) )",
+ opconvert = True,
+ expected_result = [ ["||", "A", "B"] ] ),
+ UseReduceTestCase(
+ "( || ( || ( ( A ) B ) ) )",
+ opconvert = True,
+ expected_result = [ ["||", "A", "B"] ]),
+ UseReduceTestCase(
+ "( || ( || ( ( A ) B ) ) )",
+ opconvert = True,
+ expected_result = [ ["||", "A", "B"] ]),
+ UseReduceTestCase(
+ "|| ( A )",
+ opconvert = True,
+ expected_result = ["A"]),
+ UseReduceTestCase(
+ "( || ( || ( || ( A ) foo? ( B ) ) ) )",
+ expected_result = ["A"]),
+ UseReduceTestCase(
+ "( || ( || ( || ( A ) foo? ( B ) ) ) )",
+ uselist = ["foo"],
+ opconvert = True,
+ expected_result = [ ["||", "A", "B"] ]),
+ UseReduceTestCase(
+ "( || ( || ( bar? ( A ) || ( foo? ( B ) ) ) ) )",
+ opconvert = True,
+ expected_result = []),
+ UseReduceTestCase(
+ "( || ( || ( bar? ( A ) || ( foo? ( B ) ) ) ) )",
+ uselist = ["foo", "bar"],
+ opconvert = True,
+ expected_result = [ ["||", "A", "B"] ]),
+ UseReduceTestCase(
+ "A || ( ) foo? ( ) B",
+ opconvert = True,
+ expected_result = ["A", "B"]),
+ UseReduceTestCase(
+ "|| ( A ) || ( B )",
+ opconvert = True,
+ expected_result = ["A", "B"]),
+ UseReduceTestCase(
+ "foo? ( A ) foo? ( B )",
+ opconvert = True,
+ expected_result = []),
+ UseReduceTestCase(
+ "foo? ( A ) foo? ( B )",
+ uselist = ["foo"],
+ opconvert = True,
+ expected_result = ["A", "B"]),
)
test_cases_xfail = (