aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-05-22 17:42:15 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-05-22 17:42:15 +0000
commitb69cec33730dcbc04b3e5fc2204a341eb9d55bdd (patch)
tree0d47e24a819f980d7fed8d1b79d79cfd055cbd67
parentf1d2eebbc18965e0ddf048dca276a6b06878e4eb (diff)
downloadpaludis-b69cec33730dcbc04b3e5fc2204a341eb9d55bdd.tar.gz
paludis-b69cec33730dcbc04b3e5fc2204a341eb9d55bdd.tar.xz
(python) Add EAPI stuff.
-rw-r--r--python/Makefile.am4
-rw-r--r--python/eapi.cc84
-rwxr-xr-xpython/eapi_TEST.py56
-rw-r--r--python/paludis_python_so.cc2
-rw-r--r--python/version_metadata.cc4
-rwxr-xr-xpython/version_metadata_TEST.py2
6 files changed, 147 insertions, 5 deletions
diff --git a/python/Makefile.am b/python/Makefile.am
index 9872729..0697cce 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -27,6 +27,7 @@ IF_PYTHON_TESTS = \
mask_reasons_TEST.py \
contents_TEST.py \
dep_spec_TEST.py \
+ eapi_TEST.py \
portage_dep_parser_TEST.py \
log_TEST.py \
name_TEST.py \
@@ -39,10 +40,11 @@ IF_PYTHON_TESTS = \
IF_PYTHON_QA_TESTS =
IF_PYTHON_SOURCES = \
- exception.cc \
contents.cc \
dep_spec.cc \
+ eapi.cc \
environment.cc \
+ exception.cc \
fs_entry.cc \
mask_reasons.cc \
name.cc \
diff --git a/python/eapi.cc b/python/eapi.cc
new file mode 100644
index 0000000..a0fb0c8
--- /dev/null
+++ b/python/eapi.cc
@@ -0,0 +1,84 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Piotr Jaroszyński <peper@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis_python.hh>
+
+#include <paludis/eapi.hh>
+
+using namespace paludis;
+using namespace paludis::python;
+namespace bp = boost::python;
+
+void expose_eapi()
+{
+ register_shared_ptrs_to_python<SupportedEAPI>();
+ bp::class_<SupportedEAPI, boost::noncopyable>
+ se("SupportedEAPI",
+ "Information about a supported EAPI.",
+ bp::no_init
+ );
+ se.def_readonly("package_dep_spec_parse_mode", &SupportedEAPI::package_dep_spec_parse_mode,
+ "[ro] PackageDepSpecParseMode"
+ );
+ se.def_readonly("strict_package_dep_spec_parse_mode", &SupportedEAPI::strict_package_dep_spec_parse_mode,
+ "[ro] PackageDepSpecParseMode"
+ );
+ se.def_readonly("iuse_flag_parse_mode", &SupportedEAPI::iuse_flag_parse_mode,
+ "[ro] IUseFlagParseMode"
+ );
+ se.def_readonly("strict_iuse_flag_parse_mode", &SupportedEAPI::strict_iuse_flag_parse_mode,
+ "[ro] IUseFlagParseMode"
+ );
+ se.def_readonly("breaks_portage", &SupportedEAPI::breaks_portage,
+ "[ro] bool"
+ );
+ se.def_readonly("has_pretend_phase", &SupportedEAPI::has_pretend_phase,
+ "[ro] bool"
+ );
+
+ bp::class_<EAPI>
+ e("EAPI",
+ "Information about an EAPI.",
+ bp::no_init
+ );
+ e.def_readonly("name", &EAPI::name,
+ "[ro] str"
+ );
+ e.add_property("supported", bp::make_getter(&EAPI::supported, bp::return_value_policy<bp::return_by_value>()),
+ "[ro] SupportedEAPI"
+ );
+
+ bp::class_<EAPIData, boost::noncopyable>
+ ed("EAPIData",
+ "Holds information on recognised EAPIs.",
+ bp::no_init
+ );
+ ed.add_static_property("instance", bp::make_function(&EAPIData::get_instance,
+ bp::return_value_policy<bp::reference_existing_object>()),
+ "Singleton instance."
+ );
+ ed.def("eapi_from_string", &EAPIData::eapi_from_string,
+ "eapi_from_string(str) -> EAPI\n"
+ "Make an EAPI."
+ );
+ ed.def("unknown_eapi", &EAPIData::unknown_eapi,
+ "unknown_eapi() -> EAPI\n"
+ "Make the unknown EAPI."
+ );
+}
diff --git a/python/eapi_TEST.py b/python/eapi_TEST.py
new file mode 100755
index 0000000..1b3b3c9
--- /dev/null
+++ b/python/eapi_TEST.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# vim: set fileencoding=utf-8 sw=4 sts=4 et :
+
+#
+# Copyright (c) 2007 Piotr Jaroszyński <peper@gentoo.org>
+#
+# This file is part of the Paludis package manager. Paludis is free software;
+# you can redistribute it and/or modify it under the terms of the GNU General
+# Public License version 2, as published by the Free Software Foundation.
+#
+# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+from paludis import *
+import unittest
+
+class TestCase_EAPI(unittest.TestCase):
+ def test_01_instance(self):
+ self.assert_(isinstance(EAPIData.instance, EAPIData))
+
+ def test_02_create_error(self):
+ self.assertRaises(Exception, SupportedEAPI)
+ self.assertRaises(Exception, EAPI)
+
+ def test_03_unknown_eapi(self):
+ eapi = EAPIData.instance.unknown_eapi()
+
+ self.assertEquals(eapi.name, "UNKNOWN")
+ self.assertEquals(eapi.supported, None)
+
+ def test_04_eapi(self):
+ eapi = EAPIData.instance.eapi_from_string("foo")
+
+ self.assertEquals(eapi.name, "foo")
+ self.assertEquals(eapi.supported, None)
+
+ def test_05_supported_eapi(self):
+ eapi = EAPIData.instance.eapi_from_string("paludis-1")
+
+ self.assertEquals(eapi.name, "paludis-1")
+ self.assert_(isinstance(eapi.supported.package_dep_spec_parse_mode, PackageDepSpecParseMode))
+ self.assert_(isinstance(eapi.supported.strict_package_dep_spec_parse_mode, PackageDepSpecParseMode))
+ self.assert_(isinstance(eapi.supported.iuse_flag_parse_mode, IUseFlagParseMode))
+ self.assert_(isinstance(eapi.supported.strict_iuse_flag_parse_mode, IUseFlagParseMode))
+ self.assert_(isinstance(eapi.supported.breaks_portage, bool))
+ self.assert_(isinstance(eapi.supported.has_pretend_phase, bool))
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/python/paludis_python_so.cc b/python/paludis_python_so.cc
index a037915..9731f66 100644
--- a/python/paludis_python_so.cc
+++ b/python/paludis_python_so.cc
@@ -21,6 +21,7 @@
void expose_contents();
void expose_dep_spec();
+void expose_eapi();
void expose_environment();
void expose_exception();
void expose_fs_entry();
@@ -43,6 +44,7 @@ BOOST_PYTHON_MODULE(paludis)
expose_version_operator();
expose_version_requirements();
expose_fs_entry();
+ expose_eapi();
expose_contents();
expose_mask_reasons();
expose_version_metadata();
diff --git a/python/version_metadata.cc b/python/version_metadata.cc
index 18bc7b6..0ea94d6 100644
--- a/python/version_metadata.cc
+++ b/python/version_metadata.cc
@@ -87,11 +87,9 @@ void PALUDIS_VISIBLE expose_version_metadata()
vm.def_readonly("description", &VersionMetadata::description,
"[ro] string"
);
-#ifdef CIARANM_REMOVED_THIS
vm.def_readonly("eapi", &VersionMetadata::eapi,
- "[ro] string"
+ "[ro] EAPI"
);
-#endif
vm.add_property("ebuild_interface", bp::make_function(&VersionMetadataWrapper::get_ebuild_interface,
bp::return_internal_reference<>()),
"[ro] EbuildInterface"
diff --git a/python/version_metadata_TEST.py b/python/version_metadata_TEST.py
index dd8101f..93cc5a3 100755
--- a/python/version_metadata_TEST.py
+++ b/python/version_metadata_TEST.py
@@ -50,7 +50,7 @@ class TestCase_VersionMetadata(unittest.TestCase):
self.assertEquals(str(vmd.slot), "0")
self.assertEquals(str(iter(vmd.homepage).next()), "http://paludis.pioto.org/")
self.assertEquals(vmd.description, "Test package")
-# self.assertEquals(vmd.eapi, "0")
+ self.assertEquals(vmd.eapi.name, "0")
def test_04_ebuild_interface(self):
ei = self.vmd("1.0").ebuild_interface