aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-11-20 20:25:29 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-11-20 20:25:29 +0000
commit6ae1d90a0cebdc74a3368af481b3d429a8d9c8f4 (patch)
tree37abf026812fe9a883edae4ea731ec36ebade956 /python
parentfada389df0902a4e0e975909b3d4b4e23429f4c9 (diff)
downloadpaludis-6ae1d90a0cebdc74a3368af481b3d429a8d9c8f4.tar.gz
paludis-6ae1d90a0cebdc74a3368af481b3d429a8d9c8f4.tar.xz
Make fetch_unique_qualified_package_name take a query to limit the potential results, and use it to pick out installable or installed packages when appropriate.
Diffstat (limited to 'python')
-rw-r--r--python/package_database.cc10
-rwxr-xr-xpython/package_database_TEST.py2
2 files changed, 10 insertions, 2 deletions
diff --git a/python/package_database.cc b/python/package_database.cc
index e0cedcdf0..08cb59ae2 100644
--- a/python/package_database.cc
+++ b/python/package_database.cc
@@ -31,6 +31,9 @@ using namespace paludis;
using namespace paludis::python;
namespace bp = boost::python;
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(
+ fetch_unique_qualified_package_name_overloads, fetch_unique_qualified_package_name, 1, 2)
+
void expose_package_database()
{
/**
@@ -91,8 +94,11 @@ void expose_package_database()
)
.def("fetch_unique_qualified_package_name", &PackageDatabase::fetch_unique_qualified_package_name,
- "fetch_unique_qualified_package_name(PackageNamePart) -> QualifiedPackageName\n"
- "Disambiguate a package name."
+ fetch_unique_qualified_package_name_overloads(
+ "fetch_unique_qualified_package_name(PackageNamePart[, Query]) -> QualifiedPackageName\n"
+ "Disambiguate a package name. If a query is specified, "
+ "limit the potential results to packages that match."
+ )
)
.def("more_important_than", &PackageDatabase::more_important_than,
diff --git a/python/package_database_TEST.py b/python/package_database_TEST.py
index a6300ae33..1fba70a0d 100755
--- a/python/package_database_TEST.py
+++ b/python/package_database_TEST.py
@@ -42,11 +42,13 @@ class TestCase_PackageDatabase(unittest.TestCase):
def test_03_fech_unique_qpn(self):
self.get_db()
self.assertEqual(str(QualifiedPackageName("foo/bar")), str(self.db.fetch_unique_qualified_package_name("bar")))
+ self.assertEqual(str(QualifiedPackageName("foo/bar")), str(self.db.fetch_unique_qualified_package_name("bar", Query.SupportsInstallAction())))
def test_04_exceptions(self):
self.get_db()
self.assertRaises(AmbiguousPackageNameError, self.db.fetch_unique_qualified_package_name, "baz")
self.assertRaises(NoSuchPackageError, self.db.fetch_unique_qualified_package_name, "foobarbaz")
+ self.assertRaises(NoSuchPackageError, self.db.fetch_unique_qualified_package_name, "bar", Query.SupportsUninstallAction())
def test_5_query(self):
self.get_db()