aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-03-22 16:53:29 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-03-22 16:53:29 +0000
commit882ff24ed3f781c70369045e5c394333cab4a0c0 (patch)
tree637845435886ebec9d33117bd50892e5dbb4016b
parent4420b5ced9d425a93123b5c0afe7514cb05b88c3 (diff)
downloadpaludis-882ff24ed3f781c70369045e5c394333cab4a0c0.tar.gz
paludis-882ff24ed3f781c70369045e5c394333cab4a0c0.tar.xz
Update python for versionspec changes
-rwxr-xr-xpython/dep_tag_TEST.py2
-rwxr-xr-xpython/repository_TEST.py6
-rwxr-xr-xpython/version_operator_TEST.py6
-rwxr-xr-xpython/version_requirements_TEST.py8
-rw-r--r--python/version_spec.cc19
5 files changed, 28 insertions, 13 deletions
diff --git a/python/dep_tag_TEST.py b/python/dep_tag_TEST.py
index 827d0cc..d809b0d 100755
--- a/python/dep_tag_TEST.py
+++ b/python/dep_tag_TEST.py
@@ -57,7 +57,7 @@ class TestCase_04_DependencyDepTag(unittest.TestCase):
global dt, pid, pds, cds
env = TestEnvironment()
repo = FakeRepository(env, "repo")
- pid = repo.add_version("cat/foo", "1.0")
+ pid = repo.add_version("cat/foo", VersionSpec("1.0"))
pds = parse_user_package_dep_spec("=cat/boo-1", env, [])
dt = DependencyDepTag(pid, pds);
diff --git a/python/repository_TEST.py b/python/repository_TEST.py
index 48f736a..3a34d6f 100755
--- a/python/repository_TEST.py
+++ b/python/repository_TEST.py
@@ -235,15 +235,15 @@ class TestCase_03_FakeRepository(unittest.TestCase):
f.add_package("cat-foo/pkg")
self.assertEquals(list(f.package_ids("cat-foo/pkg")), [])
- pkg = f.add_version("cat-foo/pkg", "1")
+ pkg = f.add_version("cat-foo/pkg", VersionSpec("1"))
self.assertEquals(list(f.package_ids("cat-foo/pkg")), [pkg])
self.assertEquals(pkg.version, VersionSpec("1"))
- pkg2 = f.add_version("cat-foo/pkg", "2")
+ pkg2 = f.add_version("cat-foo/pkg", VersionSpec("2"))
self.assertEquals(list(f.package_ids("cat-foo/pkg")), [pkg, pkg2])
self.assertEquals(pkg2.version, VersionSpec("2"))
- pkg3 = f.add_version("cat-bar/pkg", "0")
+ pkg3 = f.add_version("cat-bar/pkg", VersionSpec("0"))
self.assertEquals(list(f.package_ids("cat-bar/pkg")), [pkg3])
self.assertEquals([str(x) for x in f.category_names], ["cat-bar", "cat-foo"])
diff --git a/python/version_operator_TEST.py b/python/version_operator_TEST.py
index f0b8866..96118d9 100755
--- a/python/version_operator_TEST.py
+++ b/python/version_operator_TEST.py
@@ -34,9 +34,9 @@ class TestCase_VersionOperator(unittest.TestCase):
self.assertEqual("<", str(VersionOperator(VersionOperatorValue.LESS)))
def test_04_compare(self):
- self.assert_(VersionOperator("<").compare("1.0", "2.0"))
- self.assert_(VersionOperator(">").compare("3.0", "2.0"))
- self.assert_(VersionOperator(VersionOperatorValue.EQUAL_STAR).compare("2.0.1-r1", "2.0"))
+ self.assert_(VersionOperator("<").compare(VersionSpec("1.0"), VersionSpec("2.0")))
+ self.assert_(VersionOperator(">").compare(VersionSpec("3.0"), VersionSpec("2.0")))
+ self.assert_(VersionOperator(VersionOperatorValue.EQUAL_STAR).compare(VersionSpec("2.0.1-r1"), VersionSpec("2.0")))
if __name__ == "__main__":
unittest.main()
diff --git a/python/version_requirements_TEST.py b/python/version_requirements_TEST.py
index 6a54b7c..46321ed 100755
--- a/python/version_requirements_TEST.py
+++ b/python/version_requirements_TEST.py
@@ -23,13 +23,13 @@ import unittest
class TestCase_VersionRequirements(unittest.TestCase):
def test_01_init(self):
- VersionRequirement("<", "0")
- VersionRequirement(VersionOperatorValue.LESS, "0")
+ VersionRequirement("<", VersionSpec("0"))
+ VersionRequirement(VersionOperatorValue.LESS, VersionSpec("0"))
def test_02_data_members(self):
- v1 = VersionRequirement("<", "0")
+ v1 = VersionRequirement("<", VersionSpec("0"))
v1.version_operator = ">"
- v1.version_spec = "1"
+ v1.version_spec = VersionSpec("1")
self.assertEquals(str(v1.version_operator), ">")
self.assertEquals(str(v1.version_spec), "1")
diff --git a/python/version_spec.cc b/python/version_spec.cc
index f938c88..3a2f782 100644
--- a/python/version_spec.cc
+++ b/python/version_spec.cc
@@ -22,11 +22,22 @@
#include <paludis/version_spec.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/options.hh>
+#include <paludis/user_dep_spec.hh>
using namespace paludis;
using namespace paludis::python;
namespace bp = boost::python;
+namespace
+{
+ VersionSpec * make_version_spec(const std::string & s)
+ {
+ return new VersionSpec(s, user_version_spec_options());
+ }
+
+}
+
void expose_version_spec()
{
/**
@@ -39,15 +50,19 @@ void expose_version_spec()
/**
* VersionSpec
*/
- bp::implicitly_convertible<std::string, VersionSpec>();
bp::class_<VersionSpec>
(
"VersionSpec",
"A VersionSpec represents a version number (for example, 1.2.3b-r1).\n\n"
"See U{example_version_spec<###EX###../example_version_spec.html>}",
- bp::init<const std::string &>("__init__(string)")
+ bp::no_init
)
+ .def("__init__",
+ bp::make_constructor(&make_version_spec),
+ "__init__(string)"
+ )
+
.def("bump", &VersionSpec::bump,
"bump() -> VersionSpec\n"
"This is used by the ~> operator. It returns a VersionSpec where the next to last number "