aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <p.jaroszynski@gmail.com> 2008-06-16 13:10:50 +0200
committerAvatar Piotr Jaroszyński <p.jaroszynski@gmail.com> 2008-06-16 15:10:06 +0200
commitfa86b0a09fedb9b65df6da0fe08323676a1a0b56 (patch)
tree08c3c6c139d6afce093b962a991b265bd6a3883f
parent4bf02ec7bba7b3d01de7b0acdc56e9ebef35a2dd (diff)
downloadpaludis-fa86b0a09fedb9b65df6da0fe08323676a1a0b56.tar.gz
paludis-fa86b0a09fedb9b65df6da0fe08323676a1a0b56.tar.xz
(python) Update bindings for parse_user_package_dep_spec changes.
-rw-r--r--python/additional_tests.cc3
-rwxr-xr-xpython/dep_list_TEST.py2
-rw-r--r--python/dep_spec.cc10
-rwxr-xr-xpython/dep_spec_TEST.py21
-rwxr-xr-xpython/dep_tag_TEST.py2
-rwxr-xr-xpython/environment_TEST.py11
-rwxr-xr-xpython/mask_TEST.py18
-rwxr-xr-xpython/metadata_key_TEST.py10
-rw-r--r--python/paludis_python_so.cc2
9 files changed, 50 insertions, 29 deletions
diff --git a/python/additional_tests.cc b/python/additional_tests.cc
index 9c37442..f5146fe 100644
--- a/python/additional_tests.cc
+++ b/python/additional_tests.cc
@@ -280,7 +280,8 @@ namespace formatter
// CanFormat for PackageRoles
void test_package_roles(CanFormat<PackageDepSpec> & f)
{
- PackageDepSpec p(parse_user_package_dep_spec("cat/pkg", UserPackageDepSpecOptions()));
+ TestEnvironment e;
+ PackageDepSpec p(parse_user_package_dep_spec("cat/pkg", &e, UserPackageDepSpecOptions()));
f.format(p, Plain());
f.format(p, Installed());
f.format(p, Installable());
diff --git a/python/dep_list_TEST.py b/python/dep_list_TEST.py
index a40c7c6..cc781fa 100755
--- a/python/dep_list_TEST.py
+++ b/python/dep_list_TEST.py
@@ -122,7 +122,7 @@ class TestCase_02_DepList(unittest.TestCase):
env = EnvironmentMaker.instance.make_from_spec("")
dl = DepList(env, DepListOptions())
dd = env.default_destinations
- pds = parse_user_package_dep_spec("foo/bar", [])
+ pds = parse_user_package_dep_spec("foo/bar", env, [])
cds = env.set("bar")
def test_01_create(self):
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index c0e5054..3992cc8 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -25,6 +25,7 @@
#include <paludis/dep_tag.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/environment.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/version_requirements.hh>
#include <paludis/util/clone-impl.hh>
@@ -1054,6 +1055,11 @@ void expose_dep_spec()
("NotAllowedInThisHeirarchy", "BaseException",
"Thrown if a spec part not suitable for a particular heirarchy is present.");
+ ExceptionRegister::get_instance()->add_exception<GotASetNotAPackageDepSpec>
+ ("GotASetNotAPackageDepSpec", "BaseException",
+ "Thrown by parse_user_package_dep_spec if options includes THROW_IF_SET"
+ " and we're given a set.");
+
/**
* Enums
*/
@@ -1179,7 +1185,9 @@ void expose_dep_spec()
*/
bp::def("parse_user_package_dep_spec", &parse_user_package_dep_spec,
- "parse_user_package_dep_spec(str, options=UserPackageDepSpecOptions()) -> PackageDepSpec\n"
+ (bp::arg("str"), bp::arg("env"), bp::arg("options"), bp::arg("filter")=filter::All()),
+ "parse_user_package_dep_spec(str, Environment, options=UserPackageDepSpecOptions(), Filter)"
+ " -> PackageDepSpec\n"
"Create a PackageDepSpec from user input."
);
diff --git a/python/dep_spec_TEST.py b/python/dep_spec_TEST.py
index 2326fa3..b675464 100755
--- a/python/dep_spec_TEST.py
+++ b/python/dep_spec_TEST.py
@@ -23,12 +23,14 @@ import unittest
class TestCase_1_DepSpecs(unittest.TestCase):
def get_depspecs(self):
+ self.env = TestEnvironment()
self.ptds = PlainTextDepSpec("foo")
- self.pds = parse_user_package_dep_spec(">=foo/bar-1:100::testrepo", [])
- self.pds2 = parse_user_package_dep_spec("*/*::testrepo",
+ self.pds = parse_user_package_dep_spec(">=foo/bar-1:100::testrepo", self.env, [])
+ self.pds2 = parse_user_package_dep_spec("*/*::testrepo", self.env,
UserPackageDepSpecOptions() + UserPackageDepSpecOption.ALLOW_WILDCARDS)
- self.pds3 = parse_user_package_dep_spec("*/*::testrepo", [UserPackageDepSpecOption.ALLOW_WILDCARDS])
- self.pds4 = parse_user_package_dep_spec("cat/pkg::testrepo", [])
+ self.pds3 = parse_user_package_dep_spec("*/*::testrepo", self.env,
+ [UserPackageDepSpecOption.ALLOW_WILDCARDS])
+ self.pds4 = parse_user_package_dep_spec("cat/pkg::testrepo", self.env, [])
self.bds = BlockDepSpec(self.pds)
self.nds = NamedSetDepSpec("system")
@@ -36,17 +38,18 @@ class TestCase_1_DepSpecs(unittest.TestCase):
self.get_depspecs()
def test_02_create_error(self):
+ self.get_depspecs()
self.assertRaises(Exception, DepSpec)
self.assertRaises(Exception, PackageDepSpec)
self.assertRaises(Exception, StringDepSpec)
self.assertRaises(BadVersionOperatorError, parse_user_package_dep_spec,
- "<>foo/bar", UserPackageDepSpecOptions())
+ "<>foo/bar", self.env, UserPackageDepSpecOptions())
self.assertRaises(PackageDepSpecError, parse_user_package_dep_spec,
- "=foo/bar", [])
+ "=foo/bar", self.env, [])
self.assertRaises(PackageDepSpecError, parse_user_package_dep_spec,
- "*/*::testrepo", UserPackageDepSpecOptions())
+ "*/*::testrepo", self.env, UserPackageDepSpecOptions())
self.assertRaises(PackageDepSpecError, parse_user_package_dep_spec,
- "*/*::testrepo", [])
+ "*/*::testrepo", self.env, [])
def test_03_str(self):
self.get_depspecs()
@@ -85,7 +88,7 @@ class TestCase_1_DepSpecs(unittest.TestCase):
### self.assert_(isinstance(ur, EnabledUseRequirement))
def test_10_without_additional_requirements(self):
- spec = parse_user_package_dep_spec("foo/monkey[foo]", UserPackageDepSpecOptions())
+ spec = parse_user_package_dep_spec("foo/monkey[foo]", TestEnvironment(), UserPackageDepSpecOptions())
pds = spec.without_additional_requirements()
### self.assertEquals(pds.additional_requirements, None)
### self.assertEquals(str(pds), "foo/monkey")
diff --git a/python/dep_tag_TEST.py b/python/dep_tag_TEST.py
index 1b3a2ac..f98b9ce 100755
--- a/python/dep_tag_TEST.py
+++ b/python/dep_tag_TEST.py
@@ -58,7 +58,7 @@ class TestCase_04_DependencyDepTag(unittest.TestCase):
env = TestEnvironment()
repo = FakeRepository(env, "repo")
pid = repo.add_version("cat/foo", "1.0")
- pds = parse_user_package_dep_spec("=cat/boo-1", [])
+ pds = parse_user_package_dep_spec("=cat/boo-1", env, [])
cds = env.set("everything")
dt = DependencyDepTag(pid, pds, cds);
diff --git a/python/environment_TEST.py b/python/environment_TEST.py
index 599786a..a1f5d08 100755
--- a/python/environment_TEST.py
+++ b/python/environment_TEST.py
@@ -53,7 +53,7 @@ class TestCase_01_Environments(unittest.TestCase):
def test_04_query_use(self):
pid = iter(self.e[Selection.RequireExactlyOne(Generator.Matches(
- parse_user_package_dep_spec("=foo/bar-1.0", [])))]).next()
+ parse_user_package_dep_spec("=foo/bar-1.0", self.e, [])))]).next()
self.assert_(self.e.query_use("enabled", pid))
self.assert_(not self.e.query_use("not_enabled", pid))
@@ -102,8 +102,8 @@ class TestCase_02_AdaptedEnvironment(unittest.TestCase):
def test_02_adapt_use(self):
env = AdaptedEnvironment(EnvironmentMaker.instance.make_from_spec(""))
pid = iter(env[Selection.RequireExactlyOne(Generator.Matches(
- parse_user_package_dep_spec("=foo/bar-1.0", UserPackageDepSpecOptions())))]).next()
- pds = parse_user_package_dep_spec("foo/bar", [])
+ parse_user_package_dep_spec("=foo/bar-1.0", env, UserPackageDepSpecOptions())))]).next()
+ pds = parse_user_package_dep_spec("foo/bar", env, [])
self.assert_(env.query_use("enabled", pid))
self.assert_(not env.query_use("not_enabled", pid))
@@ -120,8 +120,9 @@ class TestCase_02_AdaptedEnvironment(unittest.TestCase):
def test_03_clear_adaptions(self):
env = AdaptedEnvironment(EnvironmentMaker.instance.make_from_spec(""))
- pid = iter(env[Selection.RequireExactlyOne(Generator.Matches(parse_user_package_dep_spec("=foo/bar-1.0", [])))]).next()
- pds = parse_user_package_dep_spec("foo/bar", [])
+ pid = iter(env[Selection.RequireExactlyOne(Generator.Matches(
+ parse_user_package_dep_spec("=foo/bar-1.0", env, [])))]).next()
+ pds = parse_user_package_dep_spec("foo/bar", env, [])
self.assert_(env.query_use("enabled", pid))
diff --git a/python/mask_TEST.py b/python/mask_TEST.py
index c1f25d6..93be950 100755
--- a/python/mask_TEST.py
+++ b/python/mask_TEST.py
@@ -34,7 +34,8 @@ class TestCase_01_Masks(unittest.TestCase):
self.e = EnvironmentMaker.instance.make_from_spec("")
def test_01_user_mask(self):
- q = Selection.RequireExactlyOne(Generator.Matches(parse_user_package_dep_spec("=masked/user-1.0", [])))
+ q = Selection.RequireExactlyOne(Generator.Matches(
+ parse_user_package_dep_spec("=masked/user-1.0", self.e, [])))
pid = iter(self.e[q]).next()
m = iter(pid.masks).next()
@@ -45,7 +46,8 @@ class TestCase_01_Masks(unittest.TestCase):
self.assertEquals(m.description(), "user")
def test_02_unaccepted_mask(self):
- q = Selection.RequireExactlyOne(Generator.Matches(parse_user_package_dep_spec("=masked/unaccepted-1.0", [])))
+ q = Selection.RequireExactlyOne(Generator.Matches(
+ parse_user_package_dep_spec("=masked/unaccepted-1.0", self.e, [])))
pid = iter(self.e[q]).next()
m = iter(pid.masks).next()
@@ -57,7 +59,8 @@ class TestCase_01_Masks(unittest.TestCase):
self.assert_(isinstance(m.unaccepted_key(), MetadataKeywordNameIterableKey))
def test_03_repository_mask(self):
- q = Selection.RequireExactlyOne(Generator.Matches(parse_user_package_dep_spec("=masked/repo-1.0", [])))
+ q = Selection.RequireExactlyOne(Generator.Matches(
+ parse_user_package_dep_spec("=masked/repo-1.0", self.e, [])))
pid = iter(self.e[q]).next()
m = iter(pid.masks).next()
@@ -73,7 +76,8 @@ class TestCase_01_Masks(unittest.TestCase):
self.assert_(isinstance(m.mask_key().value().comment, StringIterable))
def test_04_unsupported_mask(self):
- q = Selection.RequireExactlyOne(Generator.Matches(parse_user_package_dep_spec("=masked/unsupported-1.0", [])))
+ q = Selection.RequireExactlyOne(Generator.Matches(
+ parse_user_package_dep_spec("=masked/unsupported-1.0", self.e, [])))
pid = iter(self.e[q]).next()
m = iter(pid.masks).next()
@@ -85,7 +89,8 @@ class TestCase_01_Masks(unittest.TestCase):
self.assertEquals(m.explanation(), "Unsupported EAPI 'unsupported'")
def test_05_association_mask(self):
- q = Selection.RequireExactlyOne(Generator.Matches(parse_user_package_dep_spec("=virtual/association-1.0", [])))
+ q = Selection.RequireExactlyOne(Generator.Matches(
+ parse_user_package_dep_spec("=virtual/association-1.0", self.e, [])))
pid = iter(self.e[q]).next()
m = iter(pid.masks).next()
@@ -156,7 +161,8 @@ class TestCase_02_Masks_subclassing(unittest.TestCase):
def associated_package(self):
e = EnvironmentMaker.instance.make_from_spec("")
- q = Selection.RequireExactlyOne(Generator.Matches(parse_user_package_dep_spec("=masked/user-1.0", [])))
+ q = Selection.RequireExactlyOne(Generator.Matches(
+ parse_user_package_dep_spec("=masked/user-1.0", e, [])))
pid = iter(e[q]).next()
return pid
diff --git a/python/metadata_key_TEST.py b/python/metadata_key_TEST.py
index bf57184..a7a86af 100755
--- a/python/metadata_key_TEST.py
+++ b/python/metadata_key_TEST.py
@@ -202,16 +202,17 @@ class TestCase_02_MetadataKeys_suclassing(unittest.TestCase):
class TestKey(MetadataProvideSpecTreeKey):
def __init__(self):
MetadataProvideSpecTreeKey.__init__(self, "raw", "human", MetadataKeyType.NORMAL)
+ self.e = NoConfigEnvironment(repo_path, "/var/empty")
def value(self):
return AllDepSpec()
def pretty_print(self, f):
- pds = parse_user_package_dep_spec("cat/pkg", [])
+ pds = parse_user_package_dep_spec("cat/pkg", self.e, [])
return f.format_package_dep_spec_plain(pds)
def pretty_print_flat(self, f):
- pds = parse_user_package_dep_spec("cat/pkg", [])
+ pds = parse_user_package_dep_spec("cat/pkg", self.e, [])
return f.format_package_dep_spec_plain(pds)
test_metadata_provide_spec_tree_key(TestKey())
@@ -219,17 +220,18 @@ class TestCase_02_MetadataKeys_suclassing(unittest.TestCase):
def test_12_dependency_spec_tree(self):
class TestKey(MetadataDependencySpecTreeKey):
def __init__(self):
+ self.e = NoConfigEnvironment(repo_path, "/var/empty")
MetadataDependencySpecTreeKey.__init__(self, "raw", "human", MetadataKeyType.NORMAL)
def value(self):
return AllDepSpec()
def pretty_print(self, f):
- pds = parse_user_package_dep_spec("cat/pkg", [])
+ pds = parse_user_package_dep_spec("cat/pkg", self.e, [])
return f.format_package_dep_spec_plain(pds)
def pretty_print_flat(self, f):
- pds = parse_user_package_dep_spec("cat/pkg", [])
+ pds = parse_user_package_dep_spec("cat/pkg", self.e, [])
return f.format_package_dep_spec_plain(pds)
test_metadata_dependency_spec_tree_key(TestKey())
diff --git a/python/paludis_python_so.cc b/python/paludis_python_so.cc
index dad112c..6b9adff 100644
--- a/python/paludis_python_so.cc
+++ b/python/paludis_python_so.cc
@@ -36,6 +36,7 @@ BOOST_PYTHON_MODULE(paludis)
expose_version_requirements();
expose_fs_entry();
expose_contents();
+ expose_filter(); /* must be before dep_spec */
expose_dep_spec();
expose_dep_tag();
expose_dep_label();
@@ -50,7 +51,6 @@ BOOST_PYTHON_MODULE(paludis)
expose_package_database();
expose_repository();
expose_formatter();
- expose_filter();
expose_filtered_generator();
expose_generator();
expose_selection();