aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2012-09-14 17:40:39 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2012-09-14 18:06:37 +0100
commit7ce0a00a008983de8a8e61d33d41a4f41147db9b (patch)
treeba35068b18f5745145d0eefe02df85c0cd0aa5cc /python
parent2bff9772cc069fe98e281432bddd0b35c1e934e4 (diff)
downloadpaludis-7ce0a00a008983de8a8e61d33d41a4f41147db9b.tar.gz
paludis-7ce0a00a008983de8a8e61d33d41a4f41147db9b.tar.xz
Refactor to allow subslots
Diffstat (limited to 'python')
-rwxr-xr-xpython/dep_spec_TEST.py2
-rw-r--r--python/metadata_key.cc19
-rw-r--r--python/name.cc17
-rwxr-xr-xpython/package_id_TEST.py4
-rw-r--r--python/slot_requirement.cc74
5 files changed, 83 insertions, 33 deletions
diff --git a/python/dep_spec_TEST.py b/python/dep_spec_TEST.py
index 9b28d2828..b34a88f66 100755
--- a/python/dep_spec_TEST.py
+++ b/python/dep_spec_TEST.py
@@ -60,7 +60,7 @@ class TestCase_1_DepSpecs(unittest.TestCase):
def test_04_slot(self):
self.get_depspecs()
- self.assert_(isinstance(self.pds.slot_requirement, SlotExactRequirement))
+ self.assert_(isinstance(self.pds.slot_requirement, SlotExactPartialRequirement))
self.assertEqual(str(self.pds.slot_requirement.slot), "100")
self.assertEqual(self.pds2.slot_requirement, None)
diff --git a/python/metadata_key.cc b/python/metadata_key.cc
index fac21c807..aaa0409b0 100644
--- a/python/metadata_key.cc
+++ b/python/metadata_key.cc
@@ -26,6 +26,7 @@
#include <paludis/dep_label.hh>
#include <paludis/environment.hh>
#include <paludis/maintainer.hh>
+#include <paludis/slot.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/timestamp.hh>
@@ -57,9 +58,9 @@ class MetadataKeySptrToPythonVisitor
obj = bp::object(std::static_pointer_cast<const MetadataValueKey<std::string> >(_m_ptr));
}
- void visit(const MetadataValueKey<SlotName> &)
+ void visit(const MetadataValueKey<Slot> &)
{
- obj = bp::object(std::static_pointer_cast<const MetadataValueKey<SlotName> >(_m_ptr));
+ obj = bp::object(std::static_pointer_cast<const MetadataValueKey<Slot> >(_m_ptr));
}
void visit(const MetadataValueKey<long> &)
@@ -274,10 +275,10 @@ struct MetadataStringKeyWrapper :
};
struct MetadataSlotNameKeyWrapper :
- MetadataValueKey<SlotName> ,
- bp::wrapper<MetadataValueKey<SlotName> >
+ MetadataValueKey<Slot> ,
+ bp::wrapper<MetadataValueKey<Slot> >
{
- virtual const SlotName parse_value() const
+ virtual const Slot parse_value() const
PALUDIS_ATTRIBUTE((warn_unused_result))
{
Lock l(get_mutex());
@@ -996,14 +997,14 @@ void expose_metadata_key()
/**
* MetadataSlotNameKey
*/
- bp::register_ptr_to_python<std::shared_ptr<const MetadataValueKey<SlotName> > >();
+ bp::register_ptr_to_python<std::shared_ptr<const MetadataValueKey<Slot> > >();
bp::implicitly_convertible<std::shared_ptr<MetadataSlotNameKeyWrapper>,
std::shared_ptr<MetadataKey> >();
bp::class_<MetadataSlotNameKeyWrapper, std::shared_ptr<MetadataSlotNameKeyWrapper>,
bp::bases<MetadataKey>, boost::noncopyable>
(
"MetadataSlotNameKey",
- "A MetadataStringKey is a MetadataKey that has a SlotName as its\n"
+ "A MetadataStringKey is a MetadataKey that has a Slot as its\n"
"value.\n\n"
"This class can be subclassed in Python.",
@@ -1011,8 +1012,8 @@ void expose_metadata_key()
"__init__()"
)
)
- .def("parse_value", bp::pure_virtual(&MetadataValueKey<SlotName> ::parse_value),
- "parse_value() -> SlotName\n"
+ .def("parse_value", bp::pure_virtual(&MetadataValueKey<Slot> ::parse_value),
+ "parse_value() -> Slot\n"
"Fetch our value."
)
;
diff --git a/python/name.cc b/python/name.cc
index a2edce80c..5d98ebfba 100644
--- a/python/name.cc
+++ b/python/name.cc
@@ -25,6 +25,7 @@
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/name.hh>
+#include <paludis/slot.hh>
using namespace paludis;
using namespace paludis::python;
@@ -202,4 +203,20 @@ void expose_name()
true
);
+
+ /**
+ * Slot
+ */
+ bp::class_<Slot>
+ (
+ "Slot",
+ "Represents a slot",
+ bp::no_init
+ )
+
+ .add_property("raw_value",
+ &named_values_getter<Slot, n::raw_value, std::string, &Slot::raw_value>,
+ "[ro] String"
+ )
+ ;
}
diff --git a/python/package_id_TEST.py b/python/package_id_TEST.py
index 129571bb5..467672f8b 100755
--- a/python/package_id_TEST.py
+++ b/python/package_id_TEST.py
@@ -49,8 +49,8 @@ class TestCase_01_PackageID(unittest.TestCase):
self.assertEquals(self.ipid.version, VersionSpec("1"))
def test_04_slot(self):
- self.assertEquals(str(self.ipid.slot_key().parse_value()), "test_slot")
- self.assertEquals(str(self.pid.slot_key().parse_value()), "0")
+ self.assertEquals(str(self.ipid.slot_key().parse_value().raw_value), "test_slot")
+ self.assertEquals(str(self.pid.slot_key().parse_value().raw_value), "0")
def test_05_repository(self):
self.assertEquals(str(self.pid.repository_name), "testrepo")
diff --git a/python/slot_requirement.cc b/python/slot_requirement.cc
index e08a74b46..58acbae7e 100644
--- a/python/slot_requirement.cc
+++ b/python/slot_requirement.cc
@@ -46,14 +46,24 @@ namespace
{
}
- void visit(const SlotExactRequirement &)
+ void visit(const SlotExactPartialRequirement &)
{
- obj = bp::object(std::static_pointer_cast<const SlotExactRequirement>(_m_ptr));
+ obj = bp::object(std::static_pointer_cast<const SlotExactPartialRequirement>(_m_ptr));
}
- void visit(const SlotAnyLockedRequirement &)
+ void visit(const SlotExactFullRequirement &)
{
- obj = bp::object(std::static_pointer_cast<const SlotAnyLockedRequirement>(_m_ptr));
+ obj = bp::object(std::static_pointer_cast<const SlotExactFullRequirement>(_m_ptr));
+ }
+
+ void visit(const SlotAnyAtAllLockedRequirement &)
+ {
+ obj = bp::object(std::static_pointer_cast<const SlotAnyAtAllLockedRequirement>(_m_ptr));
+ }
+
+ void visit(const SlotAnyPartialLockedRequirement &)
+ {
+ obj = bp::object(std::static_pointer_cast<const SlotAnyPartialLockedRequirement>(_m_ptr));
}
void visit(const SlotAnyUnlockedRequirement &)
@@ -101,38 +111,60 @@ void expose_slot_requirement()
;
/**
- * SlotExactRequirement
+ * SlotExactPartialRequirement
*/
- register_shared_ptrs_to_python<SlotExactRequirement>(rsp_const);
- bp::implicitly_convertible<std::shared_ptr<SlotExactRequirement>, std::shared_ptr<SlotRequirement> >();
- bp::class_<SlotExactRequirement, std::shared_ptr<SlotExactRequirement>, bp::bases<SlotRequirement>, boost::noncopyable>
+ register_shared_ptrs_to_python<SlotExactPartialRequirement>(rsp_const);
+ bp::implicitly_convertible<std::shared_ptr<SlotExactPartialRequirement>, std::shared_ptr<SlotRequirement> >();
+ bp::class_<SlotExactPartialRequirement, std::shared_ptr<SlotExactPartialRequirement>, bp::bases<SlotRequirement>, boost::noncopyable>
(
- "SlotExactRequirement",
- "A SlotExactRequirement is a SlotRequirement for exact slot requirements, "
+ "SlotExactPartialRequirement",
+ "A SlotExactPartialRequirement is a SlotRequirement for exact slot requirements, "
"such as :3 or :=3 .",
bp::no_init
)
- .add_property("slot", &SlotExactRequirement::slot,
+ .add_property("slot", &SlotExactPartialRequirement::slot,
"[ro] SlotName\n"
"The slot in question."
)
+ ;
- .add_property("from_any_locked", &SlotExactRequirement::from_any_locked,
- "[ro] bool\n"
- "If true, indicates we are a :=3 style dependency."
- )
+ /**
+ * SlotExactFullRequirement
+ */
+ register_shared_ptrs_to_python<SlotExactFullRequirement>(rsp_const);
+ bp::implicitly_convertible<std::shared_ptr<SlotExactFullRequirement>, std::shared_ptr<SlotRequirement> >();
+ bp::class_<SlotExactFullRequirement, std::shared_ptr<SlotExactFullRequirement>, bp::bases<SlotRequirement>, boost::noncopyable>
+ (
+ "SlotExactFullRequirement",
+ "A SlotExactFullRequirement is a SlotRequirement for exact slot requirements, "
+ "such as :3/3 or :=3/3 .",
+ bp::no_init
+ )
+ ;
+
+ /**
+ * SlotAnyAtAllLockedRequirement
+ */
+ register_shared_ptrs_to_python<SlotAnyAtAllLockedRequirement>(rsp_const);
+ bp::implicitly_convertible<std::shared_ptr<SlotAnyAtAllLockedRequirement>, std::shared_ptr<SlotRequirement> >();
+ bp::class_<SlotAnyAtAllLockedRequirement, std::shared_ptr<SlotAnyAtAllLockedRequirement>, bp::bases<SlotRequirement>, boost::noncopyable>
+ (
+ "SlotAnyAtAllLockedRequirement",
+ "A SlotAnyAtAllLockedRequirement is a SlotRequirement for := slot requirements.",
+ bp::no_init
+ )
;
/**
- * SlotAnyLockedRequirement
+ * SlotAnyPartialLockedRequirement
*/
- register_shared_ptrs_to_python<SlotAnyLockedRequirement>(rsp_const);
- bp::implicitly_convertible<std::shared_ptr<SlotAnyLockedRequirement>, std::shared_ptr<SlotRequirement> >();
- bp::class_<SlotAnyLockedRequirement, std::shared_ptr<SlotAnyLockedRequirement>, bp::bases<SlotRequirement>, boost::noncopyable>
+ register_shared_ptrs_to_python<SlotAnyPartialLockedRequirement>(rsp_const);
+ bp::implicitly_convertible<std::shared_ptr<SlotAnyPartialLockedRequirement>, std::shared_ptr<SlotRequirement> >();
+ bp::class_<SlotAnyPartialLockedRequirement, std::shared_ptr<SlotAnyPartialLockedRequirement>, bp::bases<SlotRequirement>, boost::noncopyable>
(
- "SlotAnyLockedRequirement",
- "A SlotAnyLockedRequirement is a SlotRequirement for := slot requirements.",
+ "SlotAnyPartialLockedRequirement",
+ "A SlotAnyPartialLockedRequirement is a SlotRequirement for :3= slot requirements.",
bp::no_init
)
;