diff options
author | 2011-04-02 15:14:21 +0100 | |
---|---|---|
committer | 2011-04-04 08:32:59 +0100 | |
commit | 1a8319191a0c4a585fab173199a2c898c76f30c3 (patch) | |
tree | 39ae0ee349e25f0b420fbd72cc43bd4ba3007d8d /python | |
parent | f243a4014b98275a3ebb7872faadab5ba1fcafa8 (diff) | |
download | paludis-1a8319191a0c4a585fab173199a2c898c76f30c3.tar.gz paludis-1a8319191a0c4a585fab173199a2c898c76f30c3.tar.xz |
Version requirements to constraints
Diffstat (limited to 'python')
-rw-r--r-- | python/Makefile.am | 2 | ||||
-rw-r--r-- | python/dep_spec.cc | 67 | ||||
-rw-r--r-- | python/dep_spec.hh | 4 | ||||
-rwxr-xr-x | python/dep_spec_TEST.py | 12 | ||||
-rw-r--r-- | python/paludis_python.hh | 1 | ||||
-rw-r--r-- | python/paludis_python_so.cc | 1 | ||||
-rw-r--r-- | python/version_requirements.cc | 85 | ||||
-rwxr-xr-x | python/version_requirements_TEST.py | 38 |
8 files changed, 17 insertions, 193 deletions
diff --git a/python/Makefile.am b/python/Makefile.am index e58412490..e0cf4f0e1 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -42,7 +42,6 @@ IF_PYTHON_TESTS = \ repository_TEST.py \ selection_TEST.py \ version_operator_TEST.py \ - version_requirements_TEST.py \ version_spec_TEST.py IF_PYTHON_SOURCES = \ @@ -74,7 +73,6 @@ IF_PYTHON_SOURCES = \ repository.cc \ selection.cc \ version_operator.cc \ - version_requirements.cc \ version_spec.cc BUILT_SOURCES = \ diff --git a/python/dep_spec.cc b/python/dep_spec.cc index beb8fa09a..939fbeceb 100644 --- a/python/dep_spec.cc +++ b/python/dep_spec.cc @@ -26,10 +26,11 @@ #include <paludis/dep_spec.hh> #include <paludis/environment.hh> #include <paludis/user_dep_spec.hh> -#include <paludis/version_requirements.hh> #include <paludis/partially_made_package_dep_spec.hh> #include <paludis/dep_spec_data.hh> #include <paludis/package_dep_spec_constraint.hh> +#include <paludis/version_spec.hh> +#include <paludis/version_operator.hh> #include <paludis/util/save.hh> #include <paludis/util/stringify.hh> @@ -76,8 +77,7 @@ namespace paludis std::shared_ptr<const NameConstraint> package_name_constraint; std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint; std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint; - std::shared_ptr<VersionRequirements> version_requirements; - VersionRequirementsMode version_requirements_mode; + std::shared_ptr<const VersionConstraintSequence> all_versions; std::shared_ptr<const AnySlotConstraint> any_slot; std::shared_ptr<const ExactSlotConstraint> exact_slot; std::shared_ptr<const InRepositoryConstraint> in_repository; @@ -90,8 +90,7 @@ namespace paludis const std::shared_ptr<const NameConstraint> & q, const std::shared_ptr<const CategoryNamePartConstraint> & c, const std::shared_ptr<const PackageNamePartConstraint> & p, - const std::shared_ptr<VersionRequirements> & v, - const VersionRequirementsMode m, + const std::shared_ptr<const VersionConstraintSequence> & v, const std::shared_ptr<const AnySlotConstraint> & s, const std::shared_ptr<const ExactSlotConstraint> & xs, const std::shared_ptr<const InRepositoryConstraint> & ri, @@ -102,8 +101,7 @@ namespace paludis package_name_constraint(q), category_name_part_constraint(c), package_name_part_constraint(p), - version_requirements(v), - version_requirements_mode(m), + all_versions(v), any_slot(s), exact_slot(xs), in_repository(ri), @@ -232,8 +230,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) : p.package_name_constraint(), p.category_name_part_constraint(), p.package_name_part_constraint(), - std::make_shared<VersionRequirements>(), - p.version_requirements_mode(), + p.all_version_constraints(), p.any_slot_constraint(), p.exact_slot_constraint(), p.in_repository_constraint(), @@ -242,11 +239,6 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) : p.all_key_constraints(), stringify(p)) { - if (p.version_requirements_ptr()) - { - std::copy(p.version_requirements_ptr()->begin(), p.version_requirements_ptr()->end(), - _imp->version_requirements->back_inserter()); - } } PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) : @@ -255,8 +247,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) : p.package_name_constraint(), p.category_name_part_constraint(), p.package_name_part_constraint(), - std::make_shared<VersionRequirements>(), - p.version_requirements_mode(), + p.all_version_constraints(), p.any_slot_constraint(), p.exact_slot_constraint(), p.in_repository_constraint(), @@ -265,8 +256,6 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) : p.all_key_constraints(), p.py_str()) { - std::copy(p.version_requirements_ptr()->begin(), p.version_requirements_ptr()->end(), - _imp->version_requirements->back_inserter()); } PythonPackageDepSpec::~PythonPackageDepSpec() @@ -286,7 +275,12 @@ PythonPackageDepSpec::operator PackageDepSpec() const if (package_name_part_constraint()) p.package_name_part(package_name_part_constraint()->name_part()); - p.version_requirements_mode(version_requirements_mode()); + if (all_version_constraints()) + { + for (auto i(all_version_constraints()->begin()), i_end(all_version_constraints()->end()) ; + i != i_end ; ++i) + p.version_constraint((*i)->version_spec(), (*i)->version_operator(), (*i)->combiner()); + } if (any_slot_constraint()) p.any_slot_constraint(any_slot_constraint()->locking()); @@ -314,13 +308,6 @@ PythonPackageDepSpec::operator PackageDepSpec() const p.key_constraint((*i)->key(), (*i)->operation(), (*i)->pattern()); } - if (version_requirements_ptr()) - { - for (VersionRequirements::ConstIterator i(version_requirements_ptr()->begin()), - i_end(version_requirements_ptr()->end()) ; i != i_end ; ++i) - p.version_requirement(*i); - } - return p.to_package_dep_spec(); } @@ -348,22 +335,10 @@ PythonPackageDepSpec::category_name_part_constraint() const return _imp->category_name_part_constraint; } -std::shared_ptr<const VersionRequirements> -PythonPackageDepSpec::version_requirements_ptr() const +const std::shared_ptr<const VersionConstraintSequence> +PythonPackageDepSpec::all_version_constraints() const { - return _imp->version_requirements; -} - -VersionRequirementsMode -PythonPackageDepSpec::version_requirements_mode() const -{ - return _imp->version_requirements_mode; -} - -void -PythonPackageDepSpec::set_version_requirements_mode(const VersionRequirementsMode m) -{ - _imp->version_requirements_mode = m; + return _imp->all_versions; } const std::shared_ptr<const AnySlotConstraint> @@ -1248,16 +1223,6 @@ void expose_dep_spec() "Category name part constraint (may be None)." ) - .add_property("version_requirements", &PythonPackageDepSpec::version_requirements_ptr, - "[ro] VersionRequirements\n" - "Version requirements (may be None)." - ) - - .add_property("version_requirements_mode", &PythonPackageDepSpec::version_requirements_mode, - "[ro] VersionRequirementsMode\n" - "Version requirements mode." - ) - .add_property("exact_slot", &PythonPackageDepSpec::exact_slot_constraint, "[ro] ExactSlotConstraint\n" "Exact slot constraint (may be None)." diff --git a/python/dep_spec.hh b/python/dep_spec.hh index 07f89867e..4c6b28f8d 100644 --- a/python/dep_spec.hh +++ b/python/dep_spec.hh @@ -175,15 +175,13 @@ namespace paludis const std::shared_ptr<const NameConstraint> package_name_constraint() const; const std::shared_ptr<const PackageNamePartConstraint> package_name_part_constraint() const; const std::shared_ptr<const CategoryNamePartConstraint> category_name_part_constraint() const; + const std::shared_ptr<const VersionConstraintSequence> all_version_constraints() const; const std::shared_ptr<const InRepositoryConstraint> in_repository_constraint() const; const std::shared_ptr<const FromRepositoryConstraint> from_repository_constraint() const; const std::shared_ptr<const ExactSlotConstraint> exact_slot_constraint() const; const std::shared_ptr<const AnySlotConstraint> any_slot_constraint() const; const std::shared_ptr<const KeyConstraintSequence> all_key_constraints() const; - std::shared_ptr<const VersionRequirements> version_requirements_ptr() const; - VersionRequirementsMode version_requirements_mode() const; - void set_version_requirements_mode(const VersionRequirementsMode m); std::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const; std::string py_str() const; diff --git a/python/dep_spec_TEST.py b/python/dep_spec_TEST.py index 8f8e0a79e..476d7179d 100755 --- a/python/dep_spec_TEST.py +++ b/python/dep_spec_TEST.py @@ -71,18 +71,6 @@ class TestCase_1_DepSpecs(unittest.TestCase): self.assertEqual(str(self.pds.in_repository_constraint.name), "testrepo") self.assertEqual(self.pds.from_repository_constraint, None) - def test_07_version_requirements(self): - self.get_depspecs() - vrc = self.pds.version_requirements - - self.assertEquals(len(list(vrc)), 1) - self.assertEquals(iter(vrc).next().version_spec, VersionSpec("1")) - self.assertEquals(iter(vrc).next().version_operator.value, VersionOperator(">=").value) - - def test_08_version_requirements_mode(self): - self.get_depspecs() - self.assertEquals(self.pds.version_requirements_mode, VersionRequirementsMode.AND) - ### def test_09_additional_requirements(self): ### spec = parse_user_package_dep_spec("foo/monkey[foo]", UserPackageDepSpecOptions()) ### ur = iter(spec.additional_requirements).next() diff --git a/python/paludis_python.hh b/python/paludis_python.hh index 640b521bc..da8dcddad 100644 --- a/python/paludis_python.hh +++ b/python/paludis_python.hh @@ -193,7 +193,6 @@ void expose_package_id() PALUDIS_VISIBLE; void expose_repository() PALUDIS_VISIBLE; void expose_selection() PALUDIS_VISIBLE; void expose_version_operator() PALUDIS_VISIBLE; -void expose_version_requirements() PALUDIS_VISIBLE; void expose_version_spec() PALUDIS_VISIBLE; #endif diff --git a/python/paludis_python_so.cc b/python/paludis_python_so.cc index b2ac1804c..dad35d9d5 100644 --- a/python/paludis_python_so.cc +++ b/python/paludis_python_so.cc @@ -33,7 +33,6 @@ BOOST_PYTHON_MODULE(paludis) expose_exception(); expose_version_spec(); expose_version_operator(); - expose_version_requirements(); expose_fs_path(); expose_contents(); expose_filter(); /* must be before dep_spec */ diff --git a/python/version_requirements.cc b/python/version_requirements.cc deleted file mode 100644 index 3ec32da3c..000000000 --- a/python/version_requirements.cc +++ /dev/null @@ -1,85 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 Piotr Jaroszyński - * - * 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 <python/paludis_python.hh> -#include <python/iterable.hh> - -#include <paludis/version_requirements.hh> -#include <paludis/util/wrapped_forward_iterator.hh> -#include <paludis/util/make_named_values.hh> - -using namespace paludis; -using namespace paludis::python; -namespace bp = boost::python; - -namespace -{ - VersionRequirement * make_version_requirement(const VersionOperator & op, const VersionSpec & spec) - { - return new VersionRequirement(make_named_values<VersionRequirement>( - n::version_operator() = op, - n::version_spec() = spec - )); - } -} - -void expose_version_requirements() -{ - /** - * Enums - */ - enum_auto("VersionRequirementsMode", last_vr, - "Whether our version requirements are an 'and' or an 'or' set."); - - /** - * VersionRequirement - */ - bp::class_<VersionRequirement> - ( - "VersionRequirement", - bp::no_init - ) - - .def("__init__", - bp::make_constructor(&make_version_requirement), - "__init__(VersionOperator, VersionSpec)" - ) - - .add_property("version_operator", - &named_values_getter<VersionRequirement, n::version_operator, VersionOperator, &VersionRequirement::version_operator>, - &named_values_setter<VersionRequirement, n::version_operator, VersionOperator, &VersionRequirement::version_operator>, - "[rw] VersionOperator" - ) - - .add_property("version_spec", - &named_values_getter<VersionRequirement, n::version_spec, VersionSpec, &VersionRequirement::version_spec>, - &named_values_setter<VersionRequirement, n::version_spec, VersionSpec, &VersionRequirement::version_spec>, - "[rw] VersionSpec" - ) - ; - - /** - * VersionRequirements - */ - class_iterable<VersionRequirements> - ( - "VersionRequirements", - "Iterable collection of VersionRequirement instances, usually for a PackageDepSpec." - ); -} diff --git a/python/version_requirements_TEST.py b/python/version_requirements_TEST.py deleted file mode 100755 index 46321ed4f..000000000 --- a/python/version_requirements_TEST.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -# vim: set fileencoding=utf-8 sw=4 sts=4 et : - -# -# Copyright (c) 2007 Piotr Jaroszyński -# -# 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_VersionRequirements(unittest.TestCase): - def test_01_init(self): - VersionRequirement("<", VersionSpec("0")) - VersionRequirement(VersionOperatorValue.LESS, VersionSpec("0")) - - def test_02_data_members(self): - v1 = VersionRequirement("<", VersionSpec("0")) - v1.version_operator = ">" - v1.version_spec = VersionSpec("1") - - self.assertEquals(str(v1.version_operator), ">") - self.assertEquals(str(v1.version_spec), "1") - -if __name__ == "__main__": - unittest.main() |