aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-01-22 23:23:34 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-01-22 23:23:34 +0000
commitc05f56916407d1730903472718fed9576bd214c9 (patch)
tree4ee1d0cc171813a37e889e15acedaeca3d3aa50e /python
parentd145928e6b0283eb9816d34332d4d062b21598b3 (diff)
downloadpaludis-c05f56916407d1730903472718fed9576bd214c9.tar.gz
paludis-c05f56916407d1730903472718fed9576bd214c9.tar.xz
Don't store keys, IDs in masks
Diffstat (limited to 'python')
-rw-r--r--python/additional_tests.cc6
-rw-r--r--python/mask.cc37
-rwxr-xr-xpython/mask_TEST.py22
3 files changed, 31 insertions, 34 deletions
diff --git a/python/additional_tests.cc b/python/additional_tests.cc
index 0f9567bcf..cf9c73931 100644
--- a/python/additional_tests.cc
+++ b/python/additional_tests.cc
@@ -114,13 +114,13 @@ namespace mask
void test_unaccepted_mask(UnacceptedMask & m)
{
test_mask(m);
- m.unaccepted_key();
+ m.unaccepted_key_name();
}
void test_repository_mask(RepositoryMask & m)
{
test_mask(m);
- m.mask_key();
+ m.mask_key_name();
}
void test_unsupported_mask(UnsupportedMask & m)
@@ -132,7 +132,7 @@ namespace mask
void test_association_mask(AssociationMask & m)
{
test_mask(m);
- m.associated_package();
+ m.associated_package_spec();
}
}
diff --git a/python/mask.cc b/python/mask.cc
index af61d20f7..8884cd376 100644
--- a/python/mask.cc
+++ b/python/mask.cc
@@ -22,6 +22,7 @@
#include <paludis/mask.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/dep_spec.hh>
using namespace paludis;
using namespace paludis::python;
@@ -148,14 +149,14 @@ struct UnacceptedMaskWrapper :
UnacceptedMask,
bp::wrapper<UnacceptedMask>
{
- virtual const std::shared_ptr<const MetadataKey> unaccepted_key() const
+ virtual const std::string unaccepted_key_name() const
{
Lock l(get_mutex());
- if (bp::override f = get_override("unaccepted_key"))
+ if (bp::override f = get_override("unaccepted_key_name"))
return f();
else
- throw PythonMethodNotImplemented("UnacceptedMask", "unaccepted_key");
+ throw PythonMethodNotImplemented("UnacceptedMask", "unaccepted_key_name");
}
virtual char key() const
@@ -183,14 +184,14 @@ struct RepositoryMaskWrapper :
RepositoryMask,
bp::wrapper<RepositoryMask>
{
- virtual const std::shared_ptr<const MetadataKey> mask_key() const
+ virtual const std::string mask_key_name() const
{
Lock l(get_mutex());
- if (bp::override f = get_override("mask_key"))
+ if (bp::override f = get_override("mask_key_name"))
return f();
else
- throw PythonMethodNotImplemented("RepositoryMask", "mask_key");
+ throw PythonMethodNotImplemented("RepositoryMask", "mask_key_name");
}
virtual char key() const
@@ -252,14 +253,14 @@ struct AssociationMaskWrapper :
AssociationMask,
bp::wrapper<AssociationMask>
{
- virtual const std::shared_ptr<const PackageID> associated_package() const
+ virtual const PackageDepSpec associated_package_spec() const
{
Lock l(get_mutex());
- if (bp::override f = get_override("associated_package"))
+ if (bp::override f = get_override("associated_package_spec"))
return f();
else
- throw PythonMethodNotImplemented("AssociationMask", "associated_package");
+ throw PythonMethodNotImplemented("AssociationMask", "associated_package_spec");
}
virtual char key() const
@@ -392,9 +393,9 @@ void expose_mask()
"Can be subclassed in Python.",
bp::init<>()
)
- .def("unaccepted_key", bp::pure_virtual(&UnacceptedMask::unaccepted_key),
- "unaccepted_key() -> MetadataKey\n"
- "Fetch the metadata key that is not accepted."
+ .def("unaccepted_key_name", bp::pure_virtual(&UnacceptedMask::unaccepted_key_name),
+ "unaccepted_key_name() -> string\n"
+ "Fetch the name of the metadata key that is not accepted."
)
.def("key", bp::pure_virtual(&Mask::key),
@@ -424,9 +425,9 @@ void expose_mask()
"Can be subclassed in Python.",
bp::init<>()
)
- .def("mask_key", bp::pure_virtual(&RepositoryMask::mask_key),
- "mask_key() -> MetadataKey\n"
- "Fetch a metadata key explaining the mask. May return None,\n"
+ .def("mask_key_name", bp::pure_virtual(&RepositoryMask::mask_key_name),
+ "mask_key_name() -> string\n"
+ "Fetch the name of a metadata key explaining the mask. May return None,\n"
"if no more information is available."
)
@@ -493,9 +494,9 @@ void expose_mask()
"Can be subclassed in Python.",
bp::init<>()
)
- .def("associated_package", bp::pure_virtual(&AssociationMask::associated_package),
- "associated_package() -> PackageID\n"
- "Fetch the associated package."
+ .def("associated_package_spec", bp::pure_virtual(&AssociationMask::associated_package_spec),
+ "associated_package_spec() -> PackageDepSpec\n"
+ "Fetch a spec for the associated package."
)
.def("key", bp::pure_virtual(&Mask::key),
diff --git a/python/mask_TEST.py b/python/mask_TEST.py
index 426823dab..833b9c221 100755
--- a/python/mask_TEST.py
+++ b/python/mask_TEST.py
@@ -56,7 +56,7 @@ class TestCase_01_Masks(unittest.TestCase):
self.assertEquals(m.key(), "K")
self.assertEquals(m.description(), "keyword")
- self.assert_(isinstance(m.unaccepted_key(), MetadataKeywordNameIterableKey))
+ self.assertEquals(m.unaccepted_key_name(), "KEYWORDS")
def test_03_repository_mask(self):
q = Selection.RequireExactlyOne(Generator.Matches(
@@ -72,8 +72,7 @@ class TestCase_01_Masks(unittest.TestCase):
package_mask_path = os.path.realpath(os.path.join(os.getcwd(),
"mask_TEST_dir/testrepo/profiles/package.mask"))
- self.assertEquals(m.mask_key().value().mask_file, package_mask_path)
- self.assert_(isinstance(m.mask_key().value().comment, StringIterable))
+ self.assertEquals(m.mask_key_name(), "repository_mask")
def test_04_unsupported_mask(self):
q = Selection.RequireExactlyOne(Generator.Matches(
@@ -100,7 +99,7 @@ class TestCase_01_Masks(unittest.TestCase):
self.assertEquals(m.key(), "A")
self.assertEquals(m.description(), "by association")
- self.assertEquals(m.associated_package().name, "masked/repo")
+ self.assertEquals(m.associated_package_spec().package, "masked/repo")
elif os.environ.get("PALUDIS_ENABLE_VIRTUALS_REPOSITORY") != "no":
raise "oops"
@@ -123,8 +122,8 @@ class TestCase_02_Masks_subclassing(unittest.TestCase):
def description(self):
return "test"
- def unaccepted_key(self):
- return MetadataStringKey()
+ def unaccepted_key_name(self):
+ return "monkey"
test_unaccepted_mask(TestUnacceptedMask())
@@ -136,8 +135,8 @@ class TestCase_02_Masks_subclassing(unittest.TestCase):
def description(self):
return "test"
- def mask_key(self):
- return MetadataStringKey()
+ def mask_key_name(self):
+ return "monkey"
test_repository_mask(TestRepositoryMask())
@@ -162,12 +161,9 @@ class TestCase_02_Masks_subclassing(unittest.TestCase):
def description(self):
return "test"
- def associated_package(self):
+ def associated_package_spec(self):
e = EnvironmentFactory.instance.create("")
- q = Selection.RequireExactlyOne(Generator.Matches(
- parse_user_package_dep_spec("=masked/user-1.0", e, []), []))
- pid = iter(e[q]).next()
- return pid
+ return parse_user_package_dep_spec("=masked/user-1.0", e, [])
test_association_mask(TestAssociationMask())