aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Marvin Schmidt <marv@exherbo.org> 2017-02-10 12:45:45 +0100
committerAvatar Marvin Schmidt <marv@exherbo.org> 2017-02-10 16:56:05 +0100
commitd15113c505809477fcde40b05f020acb53959e89 (patch)
tree932b0e4d92075d2160bc04135c41a06a3b5c9d8b
parent5b704a9d2b1886437f5031a3270e1e5d83f441b7 (diff)
downloadpaludis-d15113c505809477fcde40b05f020acb53959e89.tar.gz
paludis-d15113c505809477fcde40b05f020acb53959e89.tar.xz
python: Expose slot(s) accessors of some SlotRequirement classes
Based on the initial work of Michał Górny <mgorny@gentoo.org> Fixes: ticket:1348 Change-Id: Id8e3fa358766caabd219d1926cd8a057304da34d
-rwxr-xr-xpython/dep_spec_TEST.py5
-rw-r--r--python/slot_requirement.cc11
2 files changed, 16 insertions, 0 deletions
diff --git a/python/dep_spec_TEST.py b/python/dep_spec_TEST.py
index 28b26ca10..c00377e3b 100755
--- a/python/dep_spec_TEST.py
+++ b/python/dep_spec_TEST.py
@@ -31,6 +31,7 @@ class TestCase_1_DepSpecs(unittest.TestCase):
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.pds5 = parse_user_package_dep_spec(">=foo/bar-1:3/4::testrepo", self.env, [])
self.bds = BlockDepSpec("!>=foo/bar-1:100::testrepo", self.pds)
self.nds = NamedSetDepSpec("system")
@@ -65,6 +66,10 @@ class TestCase_1_DepSpecs(unittest.TestCase):
self.assertEqual(self.pds2.slot_requirement, None)
+ self.assert_(isinstance(self.pds5.slot_requirement, SlotExactFullRequirement))
+ self.assertEqual(str(self.pds5.slot_requirement.slots[0]), "3")
+ self.assertEqual(str(self.pds5.slot_requirement.slots[1]), "4")
+
def test_05_package(self):
self.get_depspecs()
self.assertEqual(str(self.pds.package), "foo/bar")
diff --git a/python/slot_requirement.cc b/python/slot_requirement.cc
index 3317b56e8..292512c42 100644
--- a/python/slot_requirement.cc
+++ b/python/slot_requirement.cc
@@ -138,6 +138,7 @@ void expose_slot_requirement()
*/
register_shared_ptrs_to_python<SlotExactFullRequirement>(rsp_const);
bp::implicitly_convertible<std::shared_ptr<SlotExactFullRequirement>, std::shared_ptr<SlotRequirement> >();
+ bp::to_python_converter<std::pair<SlotName, SlotName>, pair_to_tuple<SlotName, SlotName>>();
bp::class_<SlotExactFullRequirement, std::shared_ptr<SlotExactFullRequirement>, bp::bases<SlotRequirement>, boost::noncopyable>
(
"SlotExactFullRequirement",
@@ -145,6 +146,11 @@ void expose_slot_requirement()
"such as ``:3/3`` or ``:=3/3``.",
bp::no_init
)
+
+ .add_property("slots", &SlotExactFullRequirement::slots,
+ "[ro] (SlotName, SlotName)\n"
+ "The slot parts in question."
+ )
;
/**
@@ -171,6 +177,11 @@ void expose_slot_requirement()
"A SlotAnyPartialLockedRequirement is a SlotRequirement for ``:3=`` slot requirements.",
bp::no_init
)
+
+ .add_property("slot", &SlotAnyPartialLockedRequirement::slot,
+ "[ro] SlotName\n"
+ "The slot in question."
+ )
;
/**