aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-16 19:09:18 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-16 19:09:18 +0000
commitd91e364ec2194766b7477cf482eedaa88d6acebc (patch)
tree479d9ac5ead34c630f0d771bdb527f54ebd8bc53 /python
parenta71cdd3cdc1873659745b742ed1b1756c4aa2722 (diff)
downloadpaludis-d91e364ec2194766b7477cf482eedaa88d6acebc.tar.gz
paludis-d91e364ec2194766b7477cf482eedaa88d6acebc.tar.xz
Add initial_labels to the newly specialised MetadataSpecTreeKey<DependencySpecTree>. Add EAPI paludis-1 support for labels. Let FakeRepository's EAPI be overridden.
Diffstat (limited to 'python')
-rw-r--r--python/metadata_key.cc104
1 files changed, 104 insertions, 0 deletions
diff --git a/python/metadata_key.cc b/python/metadata_key.cc
index abbcd788a..8902fb3b9 100644
--- a/python/metadata_key.cc
+++ b/python/metadata_key.cc
@@ -508,6 +508,61 @@ struct MetadataSpecTreeKeyWrapper<FetchableURISpecTree> :
}
};
+template <>
+struct MetadataSpecTreeKeyWrapper<DependencySpecTree> :
+ MetadataSpecTreeKey<DependencySpecTree>,
+ bp::wrapper<MetadataSpecTreeKey<DependencySpecTree> >
+{
+ MetadataSpecTreeKeyWrapper(const std::string & r, const std::string & h, const MetadataKeyType t) :
+ MetadataSpecTreeKey<DependencySpecTree>(r, h, t)
+ {
+ }
+
+ virtual const tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = this->get_override("value"))
+ return f();
+ else
+ throw PythonMethodNotImplemented("MetadataSpecTreeKey", "value");
+ }
+
+ virtual std::string pretty_print(const DependencySpecTree::ItemFormatter & formatter) const
+ PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = this->get_override("pretty_print"))
+ return f(boost::cref(formatter));
+ else
+ throw PythonMethodNotImplemented("MetadataSpecTreeKey", "pretty_print");
+ }
+
+ virtual std::string pretty_print_flat(const DependencySpecTree::ItemFormatter & formatter) const
+ PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = this->get_override("pretty_print_flat"))
+ return f(boost::cref(formatter));
+ else
+ throw PythonMethodNotImplemented("MetadataSpecTreeKey", "pretty_print_flat");
+ }
+
+ virtual const tr1::shared_ptr<const DependencyLabelSequence> initial_labels() const
+ PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = this->get_override("initial_labels"))
+ return f();
+ else
+ throw PythonMethodNotImplemented("MetadataSpecTreeKey", "initial_labels");
+ }
+};
+
template <typename C_>
struct class_set_key :
bp::class_<MetadataCollectionKeyWrapper<C_>, tr1::shared_ptr<MetadataCollectionKeyWrapper<C_> >,
@@ -677,6 +732,55 @@ struct class_spec_tree_key<FetchableURISpecTree> :
}
};
+template <>
+struct class_spec_tree_key<DependencySpecTree> :
+ bp::class_<MetadataSpecTreeKeyWrapper<DependencySpecTree>,
+ tr1::shared_ptr<MetadataSpecTreeKeyWrapper<DependencySpecTree> >,
+ bp::bases<MetadataKey>, boost::noncopyable>
+{
+ class_spec_tree_key(const std::string & spec_tree) :
+ bp::class_<MetadataSpecTreeKeyWrapper<DependencySpecTree>,
+ tr1::shared_ptr<MetadataSpecTreeKeyWrapper<DependencySpecTree> >,
+ bp::bases<MetadataKey>, boost::noncopyable>(
+ ("Metadata" + spec_tree + "Key").c_str(),
+ "A MetadataSpecTreeKey is a MetadataKey that holds a spec tree of some\n"
+ "kind as its value.\n\n"
+
+ "This class can be subclassed in Python.",
+ bp::init<const std::string &, const std::string &, MetadataKeyType>(
+ "__init__(raw_name, human_name, MetadataKeyType)"
+ )
+ )
+ {
+ bp::register_ptr_to_python<tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > >();
+ bp::implicitly_convertible<tr1::shared_ptr<MetadataSpecTreeKeyWrapper<DependencySpecTree> >,
+ tr1::shared_ptr<MetadataKey> >();
+
+ def("value", bp::pure_virtual(&MetadataSpecTreeKey<DependencySpecTree>::value),
+ ("value() -> " + spec_tree + "\n"
+ "Fetch our value").c_str()
+ );
+
+ def("pretty_print", bp::pure_virtual(&MetadataSpecTreeKey<DependencySpecTree>::pretty_print),
+ ("pretty_print(" + spec_tree + "Formatter) -> string\n"
+ "Return a multiline-line indented and formatted version of our\n"
+ "value, using the supplied Formatter to format individual items.").c_str()
+ );
+
+ def("pretty_print_flat", bp::pure_virtual(&MetadataSpecTreeKey<DependencySpecTree>::pretty_print_flat),
+ ("pretty_print_flat(" + spec_tree + "Formatter) -> string\n"
+ "Return a single-line formatted version of our value, using the\n"
+ "supplied Formatter to format individual items.").c_str()
+ );
+
+ def("initial_labels", bp::pure_virtual(&MetadataSpecTreeKey<DependencySpecTree>::initial_labels),
+ "initial_label() -> DependencyLabelSequence\n"
+ "Return a DependencyLabelSequence that represents the initial labels to use when\n"
+ "deciding the behaviour of individual items in the heirarchy."
+ );
+ }
+};
+
void expose_metadata_key()
{
/**