aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-05-13 22:07:37 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-05-13 22:07:37 +0000
commit475e38b07ce21378584533504532447ddde2d930 (patch)
tree1ef00b10c3f0c7ee17ec97223b36132e73bda3cb
parenta6d0ff5e2ca7b255cdaeb89f545f60485f1cd4c5 (diff)
downloadpaludis-475e38b07ce21378584533504532447ddde2d930.tar.gz
paludis-475e38b07ce21378584533504532447ddde2d930.tar.xz
(python) Bring VersionMetadata and names up to date.
-rw-r--r--python/name.cc57
-rwxr-xr-xpython/name_TEST.py11
-rw-r--r--python/version_metadata.cc52
-rwxr-xr-xpython/version_metadata_TEST.py31
4 files changed, 89 insertions, 62 deletions
diff --git a/python/name.cc b/python/name.cc
index d7e763c..da81f74 100644
--- a/python/name.cc
+++ b/python/name.cc
@@ -35,6 +35,8 @@ void PALUDIS_VISIBLE expose_name()
QualifiedPackageNameError("QualifiedPackageNameError");
static register_exception<UseFlagNameError>
UseFlagNameError("UseFlagNameError");
+ static register_exception<IUseFlagNameError>
+ IUseFlagNameError("IUseFlagNameError");
static register_exception<SlotNameError>
SlotNameError("SlotNameError");
static register_exception<RepositoryNameError>
@@ -52,7 +54,8 @@ void PALUDIS_VISIBLE expose_name()
class_collection<PackageNamePartCollection>
pnpc("PackageNamePartCollection",
- "Iterable collection of PackageNamePart instances."
+ "Iterable of PackageNamePart.\n"
+ "A collection of PackageNamePart instances."
);
class_validated<CategoryNamePart>
@@ -65,7 +68,8 @@ void PALUDIS_VISIBLE expose_name()
class_collection<CategoryNamePartCollection>
cnpc("CategoryNamePartCollection",
- "Iterable collection of CategoryNamePart instances."
+ "Iterable of CategoryNamePart.\n"
+ "A collection of CategoryNamePart instances."
);
class_validated<UseFlagName>
@@ -75,7 +79,8 @@ void PALUDIS_VISIBLE expose_name()
class_collection<UseFlagNameCollection>
ufnc("UseFlagNameCollection",
- "Iterable collection of UseFlagName instances."
+ "Iterable of UseFlagName.\n"
+ "A collection of UseFlagName instances."
);
class_validated<SlotName>
@@ -92,7 +97,8 @@ void PALUDIS_VISIBLE expose_name()
class_collection<RepositoryNameCollection>
rnc("RepositoryNameCollection",
- "Iterable collection of RepositoryName instances."
+ "Iterable of RepositoryName\n"
+ "A collection of RepositoryName instances."
);
class_validated<KeywordName>
@@ -100,6 +106,12 @@ void PALUDIS_VISIBLE expose_name()
"Holds a string that is a valid name for a KEYWORD."
);
+ class_collection<KeywordNameCollection>
+ knc("KeywordNameCollection",
+ "Iterable of KeywordName\n"
+ "A collection of KeywordName instances."
+ );
+
class_validated<SetName>
stn("SetName",
"Holds a string that is a valid name for a set."
@@ -111,6 +123,12 @@ void PALUDIS_VISIBLE expose_name()
"A collection of set names."
);
+ class_collection<InheritedCollection>
+ ic("InheritedCollection",
+ "Iterable of string\n"
+ "A collection of inherited packages."
+ );
+
register_shared_ptrs_to_python<QualifiedPackageName>();
bp::class_<QualifiedPackageName>
qpn("QualifiedPackageName",
@@ -126,12 +144,31 @@ void PALUDIS_VISIBLE expose_name()
class_collection<QualifiedPackageNameCollection>
qpnc("QualifiedPackageNameCollection",
- "Iterable collection of QualifiedPackageName instances."
+ "Iterable of QualifiedPackageName\n"
+ "A collection of QualifiedPackageName instances."
+ );
+
+ bp::class_<IUseFlag>
+ iuf("IUseFlag",
+ "Represents an IUse flag.",
+ bp::init<const std::string &, IUseFlagParseMode>("__init__(string, IUseFlagParseMode")
+ );
+ iuf.def(bp::init<const UseFlagName &, const UseFlagState &>("__init__(UseFlagName, UseFlagState)"));
+ iuf.def("__cmp__", &IUseFlag::compare);
+ iuf.def(bp::self_ns::str(bp::self));
+ iuf.def_readwrite("flag", &IUseFlag::flag,
+ "[rw] UseFlagName"
+ );
+ iuf.def_readwrite("state", &IUseFlag::state,
+ "[rw] UseFlagState"
+ );
+
+ class_collection<IUseFlagCollection>
+ iufc("IUseFlagCollection",
+ "Iterable of IUseFlag\n"
+ "A collection of use flags."
);
- bp::enum_<UseFlagState>
- ufs("UseFlagState");
- ufs.value("UNSPECIFIED", use_unspecified);
- ufs.value("DISABLED", use_disabled);
- ufs.value("ENABLED", use_enabled);
+ enum_auto("UseFlagState", last_use);
+ enum_auto("IUseFlagParseMode", last_iuse_pm);
}
diff --git a/python/name_TEST.py b/python/name_TEST.py
index 8027d88..e1d9240 100755
--- a/python/name_TEST.py
+++ b/python/name_TEST.py
@@ -33,6 +33,8 @@ class TestCase_Names(unittest.TestCase):
self.names["repo"] = RepositoryName("repo")
self.names["keyword"] = KeywordName("keyword")
self.names["set"] = SetName("set")
+ IUseFlag("foo", IUseFlagParseMode.PERMISSIVE)
+ IUseFlag("foo", UseFlagState.ENABLED)
def test_2_create_error(self):
self.assertRaises(PackageNamePartError, PackageNamePart, ":bad")
@@ -54,8 +56,12 @@ class TestCase_Names(unittest.TestCase):
for (k, v) in self.names.items():
self.assertEqual(str(v), k)
+ self.assertEqual(str(IUseFlag("foo", UseFlagState.ENABLED)), "+foo")
+
def test_4_operators(self):
self.assert_(CategoryNamePart("cat-foo") + PackageNamePart("pkg") == QualifiedPackageName("cat-foo/pkg"))
+ self.assert_(IUseFlag("foo", UseFlagState.ENABLED) == IUseFlag("+foo", IUseFlagParseMode.PERMISSIVE))
+
def test_5_data_members(self):
qpn = QualifiedPackageName("cat/foo")
@@ -66,5 +72,10 @@ class TestCase_Names(unittest.TestCase):
self.assertEqual(str(qpn.category), "blah")
self.assertEqual(str(qpn.package), "bar")
+ iuf = IUseFlag("foo", UseFlagState.ENABLED)
+ iuf.flag = "blah"
+ iuf.state = UseFlagState.DISABLED
+ self.assertEqual(str(iuf), "-blah")
+
if __name__ == "__main__":
unittest.main()
diff --git a/python/version_metadata.cc b/python/version_metadata.cc
index 2b78ff2..8c73ebf 100644
--- a/python/version_metadata.cc
+++ b/python/version_metadata.cc
@@ -81,11 +81,9 @@ void PALUDIS_VISIBLE expose_version_metadata()
vm.def_readonly("slot", &VersionMetadata::slot,
"[ro] SlotName"
);
-#ifdef CIARANM_REMOVED_THIS
vm.def_readonly("homepage", &VersionMetadata::homepage,
- "[ro] string"
+ "[ro] DepSpec"
);
-#endif
vm.def_readonly("description", &VersionMetadata::description,
"[ro] string"
);
@@ -128,29 +126,27 @@ void PALUDIS_VISIBLE expose_version_metadata()
bp::no_init
);
-#ifdef CIARANM_REMOVED_THIS
- ebuild_i.def_readonly("provide_string", &VersionMetadataEbuildInterface::provide_string,
- "[ro] string"
+ ebuild_i.def_readonly("provide", &VersionMetadataEbuildInterface::provide,
+ "[ro] DepSpec"
);
- ebuild_i.def_readonly("src_uri_string", &VersionMetadataEbuildInterface::src_uri_string,
- "[ro] string"
+ ebuild_i.def_readonly("src_uri", &VersionMetadataEbuildInterface::src_uri,
+ "[ro] DepSpec"
);
- ebuild_i.def_readonly("restrict_string", &VersionMetadataEbuildInterface::restrict_string,
- "[ro] string"
+ ebuild_i.def_readonly("restrictions", &VersionMetadataEbuildInterface::restrictions,
+ "[ro] DepSpec"
);
- ebuild_i.def_readonly("keywords_string", &VersionMetadataEbuildInterface::keywords_string,
- "[ro] string"
+ ebuild_i.def_readonly("keywords", &VersionMetadataEbuildInterface::keywords,
+ "[ro] KeywordNameCollection"
);
ebuild_i.def_readonly("eclass_keywords", &VersionMetadataEbuildInterface::eclass_keywords,
"[ro] string"
);
ebuild_i.def_readonly("iuse", &VersionMetadataEbuildInterface::iuse,
- "[ro] string"
+ "[ro] IUseFlagCollection"
);
ebuild_i.def_readonly("inherited", &VersionMetadataEbuildInterface::inherited,
- "[ro] string"
+ "[ro] InheritedCollection"
);
-#endif
bp::register_ptr_to_python<VersionMetadataEbinInterface *>();
bp::class_<VersionMetadataEbinInterface, boost::noncopyable>
@@ -158,11 +154,9 @@ void PALUDIS_VISIBLE expose_version_metadata()
"Version metadata for Ebins.",
bp::no_init
);
-#ifdef CIARANM_REMOVED_THIS
- ebin_i.def_readonly("bin_uri_string", &VersionMetadataEbinInterface::bin_uri_string,
- "[ro] string"
+ ebin_i.def_readonly("bin_uri", &VersionMetadataEbinInterface::bin_uri,
+ "[ro] DepSpec"
);
-#endif
bp::register_ptr_to_python<VersionMetadataCRANInterface *>();
bp::class_<VersionMetadataCRANInterface, boost::noncopyable>
@@ -186,20 +180,6 @@ void PALUDIS_VISIBLE expose_version_metadata()
"Dependency data for VersionMetadata.",
bp::no_init
);
-#ifdef CIARANM_REMOVED_THIS
- deps_i.def_readonly("build_depend_string", &VersionMetadataDepsInterface::build_depend_string,
- "[ro] string"
- );
- deps_i.def_readonly("run_depend_string", &VersionMetadataDepsInterface::run_depend_string,
- "[ro] string"
- );
- deps_i.def_readonly("post_depend_string", &VersionMetadataDepsInterface::post_depend_string,
- "[ro] string"
- );
- deps_i.def_readonly("suggested_depend_string", &VersionMetadataDepsInterface::suggested_depend_string,
- "[ro] string"
- );
-#endif
deps_i.add_property("build_depend", &VersionMetadataDepsInterface::build_depend,
"[ro] DepSpec"
);
@@ -244,10 +224,8 @@ void PALUDIS_VISIBLE expose_version_metadata()
"License data for VersionMetadata.",
bp::no_init
);
-#ifdef CIARANM_REMOVED_THIS
- license_i.def_readonly("license_string", &VersionMetadataLicenseInterface::license_string,
- "[ro] string"
+ license_i.def_readonly("license", &VersionMetadataLicenseInterface::license,
+ "[ro] DepSpec"
);
-#endif
}
diff --git a/python/version_metadata_TEST.py b/python/version_metadata_TEST.py
index 58083ae..7af541b 100755
--- a/python/version_metadata_TEST.py
+++ b/python/version_metadata_TEST.py
@@ -48,7 +48,7 @@ class TestCase_VersionMetadata(unittest.TestCase):
vmd = self.vmd("1.0")
self.assertEquals(str(vmd.slot), "0")
-# self.assertEquals(vmd.homepage, "http://paludis.pioto.org/")
+ self.assertEquals(str(iter(vmd.homepage).next()), "http://paludis.pioto.org/")
self.assertEquals(vmd.description, "Test package")
self.assertEquals(vmd.eapi, "0")
@@ -59,13 +59,13 @@ class TestCase_VersionMetadata(unittest.TestCase):
self.assert_(isinstance(ei, VersionMetadataEbuildInterface))
self.assert_(isinstance(ei2, VersionMetadataEbuildInterface))
-# self.assertEquals(ei.provide_string, "")
-# self.assertEquals(ei.src_uri_string, "http://example.com/bar-1.0.tar.bz2")
-# self.assertEquals(ei.restrict_string, "monkey")
-# self.assertEquals(ei.keywords_string, "test ")
-# self.assertEquals(ei.eclass_keywords, "")
-# self.assertEquals(ei.iuse, " ")
-# self.assertEquals(ei.inherited, "")
+ self.assertEquals(len(list(ei.provide)), 0)
+ self.assertEquals(str(iter(ei.src_uri).next()), "http://example.com/bar-1.0.tar.bz2")
+ self.assertEquals(str(iter(ei.restrictions).next()), "monkey")
+ self.assertEquals(str(iter(ei.keywords).next()), "test")
+ self.assertEquals(len(list(ei.eclass_keywords)), 0)
+ self.assertEquals(len(list(ei.iuse)), 0)
+ self.assertEquals(len(list(ei.inherited)), 0)
def test_05_ebin_interface_TODO(self):
pass
@@ -80,16 +80,17 @@ class TestCase_VersionMetadata(unittest.TestCase):
self.assert_(isinstance(di, VersionMetadataDepsInterface))
self.assert_(isinstance(di2, VersionMetadataDepsInterface))
-# self.assertEquals(di.build_depend_string.strip(), "foo/bar")
-# self.assertEquals(di.run_depend_string.strip(), "")
-# self.assertEquals(di.post_depend_string.strip(), "")
-# self.assertEquals(di.suggested_depend_string, "")
-
self.assert_(isinstance(di.build_depend, AllDepSpec))
self.assert_(isinstance(di.run_depend, AllDepSpec))
self.assert_(isinstance(di.suggested_depend, AllDepSpec))
self.assert_(isinstance(di.post_depend, AllDepSpec))
+ self.assertEquals(str(iter(di.build_depend).next()), "foo/bar")
+ self.assertEquals(len(list(di.run_depend)), 0)
+ self.assertEquals(len(list(di.post_depend)), 0)
+ self.assertEquals(len(list(di.suggested_depend)), 0)
+
+
def test_08_origins_interface(self):
oi = self.vmd_vdb("cat-one/pkg-one", "1").origins_interface
@@ -108,8 +109,8 @@ class TestCase_VersionMetadata(unittest.TestCase):
self.assert_(isinstance(li, VersionMetadataLicenseInterface))
self.assert_(isinstance(li2, VersionMetadataLicenseInterface))
-# self.assertEquals(li.license_string, "GPL-2")
-# self.assertEquals(li2.license_string, "")
+ self.assertEquals(str(iter(li.license).next()), "GPL-2")
+ self.assertEquals(len(list(li2.license)), 0)
if __name__ == "__main__":
unittest.main()