aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-12-16 00:39:14 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-12-16 00:39:14 +0000
commit9e40f93e3479dbc0407157ad9e00a2190a23cb83 (patch)
tree9c1407e434141aa4b3cfbba956859639ba7f65c7
parent888d77a8cc753f9718f22b93773e08d16e03918a (diff)
downloadpaludis-9e40f93e3479dbc0407157ad9e00a2190a23cb83.tar.gz
paludis-9e40f93e3479dbc0407157ad9e00a2190a23cb83.tar.xz
(python) Add *_key to PackageID.
-rw-r--r--python/metadata_key.cc5
-rw-r--r--python/package_id.cc101
-rwxr-xr-xpython/package_id_TEST.py93
-rwxr-xr-xpython/package_id_TEST_setup.sh3
4 files changed, 195 insertions, 7 deletions
diff --git a/python/metadata_key.cc b/python/metadata_key.cc
index b4e1d21..abbcd78 100644
--- a/python/metadata_key.cc
+++ b/python/metadata_key.cc
@@ -348,7 +348,9 @@ struct MetadataCollectionKeyWrapper :
throw PythonMethodNotImplemented("MetadataCollectionKey", "value");
}
- std::string pretty_print_flat(const Formatter<typename C_::value_type> & formatter) const
+ std::string pretty_print_flat(const Formatter<
+ typename tr1::remove_const<
+ typename RemoveSharedPtr<typename C_::value_type>::Type>::type> & formatter) const
PALUDIS_ATTRIBUTE((warn_unused_result))
{
Lock l(get_mutex());
@@ -924,6 +926,7 @@ void expose_metadata_key()
class_set_key<IUseFlagSet>("IUseFlagIterable");
class_set_key<Set<std::string> >("StringIterable");
class_set_key<FSEntrySequence>("FSEntryIterable");
+ class_set_key<PackageIDSequence>("PackageIDIterable");
/**
* MetadataSpecTreeKeys
diff --git a/python/package_id.cc b/python/package_id.cc
index 27fa688..29ddbb6 100644
--- a/python/package_id.cc
+++ b/python/package_id.cc
@@ -112,6 +112,107 @@ void expose_package_id()
"NEED_DOC"
)
+ .def("virtual_for_key", &PackageID::virtual_for_key,
+ "The virtual_for_key, if not None, indicates that we are an\n"
+ "(old-style) virtual for another package. This affects dependency\n"
+ " resolution."
+ )
+
+ .def("keywords_key", &PackageID::keywords_key,
+ "The keywords_key, if not None, is used by FindUnusedPackagesTask\n"
+ "to determine whether a package is unused."
+ )
+
+ .def("iuse_key", &PackageID::iuse_key,
+ "The iuse_key, if not None, is used when displaying single-line\n"
+ "install-pretend output, and when resolving where DepList's\n"
+ "DepListReinstallOption is dl_reinstall_if_use_changed."
+ )
+
+ .def("provide_key", &PackageID::provide_key,
+ "The provide_key, if not None, indicates that a package provides\n"
+ "certain old-style virtuals. This affects dependency resolution."
+ )
+
+ .def("contains_key", &PackageID::contains_key,
+ "The contains_key, if not None, indicates that a package contains\n"
+ "other packages. This affects dependency resolution."
+ )
+
+ .def("contained_in_key", &PackageID::contained_in_key,
+ "The contained_in_key, if not None, indicates that a package is\n"
+ "contained in another package. This affects dependency resolution."
+ )
+
+ .def("build_dependencies_key", &PackageID::build_dependencies_key,
+ "The build_dependencies_key, if not None, indicates a package's\n"
+ "build-time dependencies."
+ )
+
+ .def("run_dependencies_key", &PackageID::run_dependencies_key,
+ "The run_dependencies_key, if not None, indicates a package's\n"
+ "run-time dependencies."
+ )
+
+ .def("post_dependencies_key", &PackageID::post_dependencies_key,
+ "The post_dependencies_key, if not None, indicates a package's\n"
+ "post-merge dependencies."
+ )
+
+ .def("suggested_dependencies_key", &PackageID::suggested_dependencies_key,
+ "The suggested_dependencies_key, if not None, indicates a package's\n"
+ "suggested post-merge dependencies."
+ )
+
+ .def("fetches_key", &PackageID::fetches_key,
+ "The fetches_key, if not None, indicates files that have to be fetched\n"
+ "in order to install a package."
+ )
+
+ .def("homepage_key", &PackageID::homepage_key,
+ "The homepage_key, if not None, describes a package's homepages."
+ )
+
+ .def("short_description_key", &PackageID::short_description_key,
+ "The short_description_key, if not None, provides a short (no more\n"
+ "than a few hundred characters) description of a package."
+ )
+
+ .def("long_description_key", &PackageID::long_description_key,
+ "The long_description_key, if not None, provides a long\n"
+ "description of a package."
+ )
+
+ .def("contents_key", &PackageID::contents_key,
+ "The contents_key, if not None, contains the contents of a\n"
+ "package. For installed packages, this means the files installed;\n"
+ "for installable packages, this means the files that will be\n"
+ "installed (if known, which it may be for some binary packages)."
+ )
+
+
+ .def("installed_time_key", &PackageID::installed_time_key,
+ "The installed_time_key, if not None, contains the time a package\n"
+ "was installed. It affects dependency resolution if DepList is\n"
+ "using dl_reinstall_scm_daily or dl_reinstall_scm_weekly."
+ )
+
+ .def("source_origin_key", &PackageID::source_origin_key,
+ "The source_origin_key, if not None, contains a string describing\n"
+ "the source repository whence a package originated."
+ )
+
+ .def("binary_origin_key", &PackageID::binary_origin_key,
+ "The binary_origin_key, if not None, contains a string describing\n"
+ "the binary repository whence a package originated."
+ )
+
+ .def("fs_location_key", &PackageID::fs_location_key,
+ "The fs_location_key, if not None, indicates the filesystem\n"
+ "location (for example, the ebuild file or VDB directory) that\n"
+ "best describes the location of a PackageID."
+ )
+
.def("__eq__", &py_eq<PackageID>)
.def("__ne__", &py_ne<PackageID>)
diff --git a/python/package_id_TEST.py b/python/package_id_TEST.py
index bcbda4c..aee738b 100755
--- a/python/package_id_TEST.py
+++ b/python/package_id_TEST.py
@@ -33,6 +33,7 @@ class TestCase_01_PackageID(unittest.TestCase):
self.e = NoConfigEnvironment(repo_path, "/var/empty")
self.ie = NoConfigEnvironment(irepo_path)
self.pid = iter(self.e.package_database.fetch_repository("testrepo").package_ids("foo/bar")).next()
+ self.vpid = iter(self.e.package_database.fetch_repository("virtuals").package_ids("virtual/bar")).next()
self.ipid = iter(self.ie.package_database.fetch_repository("installed").package_ids("cat-one/pkg-one")).next()
self.mpid = iter(self.e.package_database.fetch_repository("testrepo").package_ids("cat/masked")).next()
@@ -56,17 +57,27 @@ class TestCase_01_PackageID(unittest.TestCase):
self.assertEquals(str(self.ipid.repository.name), "installed")
def test_07_canonical_form(self):
- self.assertEquals(self.pid.canonical_form(PackageIDCanonicalForm.FULL), "foo/bar-1.0::testrepo")
+ # Load the metadata
+ self.pid.slot
+ self.ipid.slot
+
+ self.assertEquals(self.pid.canonical_form(PackageIDCanonicalForm.FULL), "foo/bar-1.0:0::testrepo")
self.assertEquals(self.pid.canonical_form(PackageIDCanonicalForm.VERSION), "1.0")
- self.assertEquals(self.pid.canonical_form(PackageIDCanonicalForm.NO_VERSION), "foo/bar::testrepo")
+ self.assertEquals(self.pid.canonical_form(PackageIDCanonicalForm.NO_VERSION), "foo/bar:0::testrepo")
- self.assertEquals(self.ipid.canonical_form(PackageIDCanonicalForm.FULL), "cat-one/pkg-one-1::installed")
+ self.assertEquals(self.ipid.canonical_form(PackageIDCanonicalForm.FULL),
+ "cat-one/pkg-one-1:test_slot::installed")
self.assertEquals(self.ipid.canonical_form(PackageIDCanonicalForm.VERSION), "1")
- self.assertEquals(self.ipid.canonical_form(PackageIDCanonicalForm.NO_VERSION), "cat-one/pkg-one::installed")
+ self.assertEquals(self.ipid.canonical_form(PackageIDCanonicalForm.NO_VERSION),
+ "cat-one/pkg-one:test_slot::installed")
def test_08_str(self):
- self.assertEquals(str(self.pid), "foo/bar-1.0::testrepo")
- self.assertEquals(str(self.ipid), "cat-one/pkg-one-1::installed")
+ # Load the metadata
+ self.pid.slot
+ self.ipid.slot
+
+ self.assertEquals(str(self.pid), "foo/bar-1.0:0::testrepo")
+ self.assertEquals(str(self.ipid), "cat-one/pkg-one-1:test_slot::installed")
def test_09_find_metadata(self):
self.assert_(isinstance(self.pid.find_metadata("DEPEND"), MetadataDependencySpecTreeKey))
@@ -101,5 +112,75 @@ class TestCase_01_PackageID(unittest.TestCase):
mask = iter(self.mpid.masks).next()
self.assert_(isinstance(mask, UnacceptedMask))
+ def test_14_virtual_for_key(self):
+ self.assertEquals(self.vpid.virtual_for_key().value(), self.pid)
+ self.assertEquals(self.pid.virtual_for_key(), None)
+ self.assertEquals(self.ipid.virtual_for_key(), None)
+
+ def test_15_provide_key(self):
+ self.assert_(isinstance(self.pid.provide_key(), MetadataProvideSpecTreeKey))
+ self.assertEquals(self.ipid.provide_key(), None)
+
+ def test_16_contains_key(self):
+ self.assertEquals(self.pid.contains_key(), None)
+ self.assertEquals(self.ipid.contains_key(), None)
+
+ def test_17_contained_in_key(self):
+ self.assertEquals(self.pid.contained_in_key(), None)
+ self.assertEquals(self.ipid.contained_in_key(), None)
+
+ def test_18_build_dependencies_key(self):
+ self.assert_(isinstance(self.pid.build_dependencies_key(), MetadataDependencySpecTreeKey))
+ self.assertEquals(self.ipid.build_dependencies_key(), None)
+
+ def test_19_run_dependencies_key(self):
+ self.assert_(isinstance(self.pid.run_dependencies_key(), MetadataDependencySpecTreeKey))
+ self.assertEquals(self.ipid.run_dependencies_key(), None)
+
+ def test_20_post_dependencies_key(self):
+ self.assert_(isinstance(self.pid.post_dependencies_key(), MetadataDependencySpecTreeKey))
+ self.assertEquals(self.ipid.post_dependencies_key(), None)
+
+ def test_21_suggested_dependencies_key(self):
+ self.assertEquals(self.pid.suggested_dependencies_key(), None)
+ self.assertEquals(self.ipid.suggested_dependencies_key(), None)
+
+ def test_22_fetches_key(self):
+ self.assert_(isinstance(self.pid.fetches_key(), MetadataFetchableURISpecTreeKey))
+ self.assertEquals(self.ipid.fetches_key(), None)
+
+ def test_23_homepage_key(self):
+ self.assert_(isinstance(self.pid.homepage_key(), MetadataSimpleURISpecTreeKey))
+ self.assertEquals(self.ipid.homepage_key(), None)
+
+ def test_24_short_description_key(self):
+ self.assertEquals(self.pid.short_description_key().value(), "Test package")
+ self.assertEquals(self.ipid.short_description_key().value(), "a description")
+
+ def test_25_long_description_key(self):
+ self.assertEquals(self.pid.long_description_key(), None)
+ self.assertEquals(self.ipid.long_description_key(), None)
+
+ def test_26_contents_key(self):
+ self.assertEquals(self.pid.contents_key(), None)
+ self.assert_(isinstance(self.ipid.contents_key(), MetadataContentsKey))
+
+ def test_27_installed_time_key(self):
+ self.assertEquals(self.pid.installed_time_key(), None)
+ self.assert_(isinstance(self.ipid.installed_time_key(), MetadataTimeKey))
+
+ def test_28_source_origin_key(self):
+ self.assertEquals(self.pid.source_origin_key(), None)
+ self.assertEquals(self.ipid.source_origin_key().value(), "origin_test")
+
+ def test_29_binary_origin_key(self):
+ self.assertEquals(self.pid.binary_origin_key(), None)
+ self.assertEquals(self.ipid.binary_origin_key(), None)
+
+ def test_30_fs_location_key(self):
+ self.assert_(isinstance(self.ipid.fs_location_key(), MetadataFSEntryKey))
+ self.assert_(isinstance(self.ipid.fs_location_key(), MetadataFSEntryKey))
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/python/package_id_TEST_setup.sh b/python/package_id_TEST_setup.sh
index af0967c..a8286d5 100755
--- a/python/package_id_TEST_setup.sh
+++ b/python/package_id_TEST_setup.sh
@@ -19,6 +19,9 @@ ARCH=test
USERLAND=test
KERNEL=test
END
+cat <<END > profiles/testprofile/virtuals
+virtual/bar foo/bar
+END
cat <<"END" > foo/bar/bar-1.0.ebuild || exit 1
DESCRIPTION="Test package"