aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-10 15:01:01 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-10 15:00:36 +0000
commit415bcee8f9973e93163fe2a17111a5fa30984d06 (patch)
treee54b27661e585ce029d7fb0a8783827b51d5545b
parent18869f78fbc0cdc0730ec614cf17c427cf1dbd75 (diff)
downloadpaludis-415bcee8f9973e93163fe2a17111a5fa30984d06.tar.gz
paludis-415bcee8f9973e93163fe2a17111a5fa30984d06.tar.xz
(python) Repository metadata key bindings
Fixes: ticket:686
-rw-r--r--python/repository.cc34
-rwxr-xr-xpython/repository_TEST.py7
2 files changed, 41 insertions, 0 deletions
diff --git a/python/repository.cc b/python/repository.cc
index fbd1027..b343c73 100644
--- a/python/repository.cc
+++ b/python/repository.cc
@@ -92,6 +92,16 @@ struct RepositoryWrapper :
{
return self.qa_interface();
}
+
+ static PyObject *
+ find_metadata(const Repository & self, const std::string & key)
+ {
+ Repository::MetadataConstIterator i(self.find_metadata(key));
+ if (i != self.end_metadata())
+ return bp::incref(bp::object(*i).ptr());
+ else
+ return Py_None;
+ }
};
struct FakeRepositoryWrapper
@@ -251,6 +261,30 @@ void expose_repository()
bp::return_internal_reference<>()),
"[ro] RepositoryQAInterface"
)
+
+ .def("format_key", &Repository::format_key,
+ "The format_key, if not None, holds our repository's format"
+ )
+
+ .def("location_key", &Repository::location_key,
+ "The location_key, if not None, holds a file or directory containing "
+ "our repository's data."
+ )
+
+ .def("installed_root_key", &Repository::installed_root_key,
+ "The installed_root_key, if not None, specifies that we contain installed "
+ "packages at the specified root."
+ )
+
+ .add_property("metadata", bp::range(&Repository::begin_metadata, &Repository::end_metadata),
+ "[ro] Iterable of MetadataKey\n"
+ "NEED_DOC"
+ )
+
+ .def("find_metadata", &RepositoryWrapper::find_metadata,
+ "find_metadata(string) -> MetadataKey\n"
+ "NEED_DOC"
+ )
;
/**
diff --git a/python/repository_TEST.py b/python/repository_TEST.py
index db9483c..48f736a 100755
--- a/python/repository_TEST.py
+++ b/python/repository_TEST.py
@@ -93,6 +93,13 @@ class TestCase_01_Repository(unittest.TestCase):
self.assert_(not repo.some_ids_might_support_action(SupportsConfigActionTest()))
self.assert_(irepo.some_ids_might_support_action(SupportsConfigActionTest()))
+ def test_12_keys(self):
+ self.assert_(repo.location_key())
+ self.assertEquals(repo.location_key().value(), repo_path)
+ self.assert_(repo.find_metadata("format"))
+ self.assertEquals(repo.find_metadata("format").value(), "ebuild")
+ self.assert_(not repo.find_metadata("asdf"))
+
class TestCase_02_RepositoryInterfaces(unittest.TestCase):
def setUp(self):
global e, nce, db, repo, irepo