aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/Makefile.am1
-rw-r--r--python/dep_spec.cc27
-rw-r--r--python/dep_spec.hh3
-rwxr-xr-xpython/dep_spec_TEST.py2
-rwxr-xr-xpython/mask_TEST.py2
-rw-r--r--python/package_dep_spec_constraint.cc77
-rw-r--r--python/paludis_python.hh1
-rw-r--r--python/paludis_python_so.cc1
8 files changed, 98 insertions, 16 deletions
diff --git a/python/Makefile.am b/python/Makefile.am
index 4a275959e..e58412490 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -70,6 +70,7 @@ IF_PYTHON_SOURCES = \
nice_names-nn.hh nice_names-nn.cc \
log.cc \
package_id.cc \
+ package_dep_spec_constraint.cc \
repository.cc \
selection.cc \
version_operator.cc \
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index b53d3a768..98f009e56 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -29,6 +29,7 @@
#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/util/save.hh>
#include <paludis/util/stringify.hh>
@@ -72,7 +73,7 @@ namespace paludis
template<>
struct Imp<PythonPackageDepSpec>
{
- std::shared_ptr<const QualifiedPackageName> package_ptr;
+ std::shared_ptr<const NameConstraint> package_name_constraint;
std::shared_ptr<const CategoryNamePart> category_name_part_ptr;
std::shared_ptr<const PackageNamePart> package_name_part_ptr;
std::shared_ptr<VersionRequirements> version_requirements;
@@ -84,7 +85,7 @@ namespace paludis
const std::string str;
Imp(
- const std::shared_ptr<const QualifiedPackageName> & q,
+ const std::shared_ptr<const NameConstraint> & q,
const std::shared_ptr<const CategoryNamePart> & c,
const std::shared_ptr<const PackageNamePart> & p,
const std::shared_ptr<VersionRequirements> & v,
@@ -94,7 +95,7 @@ namespace paludis
const std::shared_ptr<const RepositoryName> & rf,
const std::shared_ptr<const AdditionalPackageDepSpecRequirements> & u,
const std::string & st) :
- package_ptr(q),
+ package_name_constraint(q),
category_name_part_ptr(c),
package_name_part_ptr(p),
version_requirements(v),
@@ -222,7 +223,7 @@ deep_copy(const std::shared_ptr<const T_> & x)
PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) :
PythonStringDepSpec(p.text()),
_imp(
- deep_copy(p.package_ptr()),
+ p.package_name_constraint(),
deep_copy(p.category_name_part_ptr()),
deep_copy(p.package_name_part_ptr()),
std::make_shared<VersionRequirements>(),
@@ -243,7 +244,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) :
PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) :
PythonStringDepSpec(p.text()),
_imp(
- deep_copy(p.package_ptr()),
+ p.package_name_constraint(),
deep_copy(p.category_name_part_ptr()),
deep_copy(p.package_name_part_ptr()),
std::make_shared<VersionRequirements>(),
@@ -266,8 +267,8 @@ PythonPackageDepSpec::operator PackageDepSpec() const
{
PartiallyMadePackageDepSpec p((PartiallyMadePackageDepSpecOptions()));
- if (package_ptr())
- p.package(*package_ptr());
+ if (package_name_constraint())
+ p.package(package_name_constraint()->name());
if (category_name_part_ptr())
p.category_name_part(*category_name_part_ptr());
@@ -309,10 +310,10 @@ PythonPackageDepSpec::operator std::shared_ptr<PackageDepSpec>() const
return std::make_shared<PackageDepSpec>(*this);
}
-std::shared_ptr<const QualifiedPackageName>
-PythonPackageDepSpec::package_ptr() const
+const std::shared_ptr<const NameConstraint>
+PythonPackageDepSpec::package_name_constraint() const
{
- return _imp->package_ptr;
+ return _imp->package_name_constraint;
}
std::shared_ptr<const PackageNamePart>
@@ -1200,9 +1201,9 @@ void expose_dep_spec()
bp::no_init
)
- .add_property("package", &PythonPackageDepSpec::package_ptr,
- "[ro] QualifiedPackageName\n"
- "Qualified package name."
+ .add_property("package_name_constraint", &PythonPackageDepSpec::package_name_constraint,
+ "[ro] NameConstraint\n"
+ "Qualified package name constraint (may be None)."
)
.add_property("package_name_part", &PythonPackageDepSpec::package_name_part_ptr,
diff --git a/python/dep_spec.hh b/python/dep_spec.hh
index 1a10fc191..f8e2be04d 100644
--- a/python/dep_spec.hh
+++ b/python/dep_spec.hh
@@ -172,7 +172,8 @@ namespace paludis
operator PackageDepSpec() const;
operator std::shared_ptr<PackageDepSpec>() const;
- std::shared_ptr<const QualifiedPackageName> package_ptr() const;
+ const std::shared_ptr<const NameConstraint> package_name_constraint() const;
+
std::shared_ptr<const PackageNamePart> package_name_part_ptr() const;
std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const;
std::shared_ptr<const VersionRequirements> version_requirements_ptr() const;
diff --git a/python/dep_spec_TEST.py b/python/dep_spec_TEST.py
index ec22662c4..d762401dc 100755
--- a/python/dep_spec_TEST.py
+++ b/python/dep_spec_TEST.py
@@ -64,7 +64,7 @@ class TestCase_1_DepSpecs(unittest.TestCase):
def test_05_package(self):
self.get_depspecs()
- self.assertEqual(str(self.pds.package), "foo/bar")
+ self.assertEqual(str(self.pds.package_name_constraint.name), "foo/bar")
def test_06_in_from_repository(self):
self.get_depspecs()
diff --git a/python/mask_TEST.py b/python/mask_TEST.py
index f38a2dad3..40262ff86 100755
--- a/python/mask_TEST.py
+++ b/python/mask_TEST.py
@@ -98,7 +98,7 @@ class TestCase_01_Masks(unittest.TestCase):
self.assertEquals(m.key(), "A")
self.assertEquals(m.description(), "by association")
- self.assertEquals(m.associated_package_spec().package, "masked/repo")
+ self.assertEquals(m.associated_package_spec().package_name_constraint.name, "masked/repo")
elif os.environ.get("PALUDIS_ENABLE_VIRTUALS_REPOSITORY") != "no":
raise "oops"
diff --git a/python/package_dep_spec_constraint.cc b/python/package_dep_spec_constraint.cc
new file mode 100644
index 000000000..aa212eb62
--- /dev/null
+++ b/python/package_dep_spec_constraint.cc
@@ -0,0 +1,77 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Piotr JaroszyƄski
+ * Copyright (c) 2011 Ciaran McCreesh
+ *
+ * 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 <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/fs_path.hh>
+#include <paludis/package_dep_spec_constraint.hh>
+
+using namespace paludis;
+using namespace paludis::python;
+namespace bp = boost::python;
+
+// For classes derived from PackageDepSpecConstraint
+template <typename C_>
+class class_package_dep_spec_constraint :
+ public bp::class_<C_, std::shared_ptr<C_>, bp::bases<PackageDepSpecConstraint>, boost::noncopyable>
+{
+ public:
+ template <class Init_>
+ class_package_dep_spec_constraint(const std::string & name, const std::string & class_doc, Init_ initspec) :
+ bp::class_<C_, std::shared_ptr<C_>, bp::bases<PackageDepSpecConstraint>, boost::noncopyable>(
+ name.c_str(), class_doc.c_str(), initspec)
+ {
+ bp::register_ptr_to_python<std::shared_ptr<const C_> >();
+ bp::implicitly_convertible<std::shared_ptr<C_>, std::shared_ptr<PackageDepSpecConstraint> >();
+ }
+};
+
+void expose_package_dep_spec_constraint()
+{
+ /**
+ * PackageDepSpecConstraint
+ */
+ bp::register_ptr_to_python<std::shared_ptr<const PackageDepSpecConstraint> >();
+ bp::implicitly_convertible<std::shared_ptr<PackageDepSpecConstraint>,
+ std::shared_ptr<const PackageDepSpecConstraint> >();
+ bp::class_<PackageDepSpecConstraint, boost::noncopyable>
+ (
+ "PackageDepSpecConstraint",
+ "Base class for a constraint for a PackageDepSpec.",
+ bp::no_init
+ )
+ ;
+
+ /**
+ * NameConstraint
+ */
+ class_package_dep_spec_constraint<NameConstraint>
+ (
+ "NameConstraint",
+ "A cat/pkg constraint for a PackageDepSpec.",
+ bp::no_init
+ )
+
+ .add_property("name", &NameConstraint::name,
+ "[RO] The cat/pkg in question"
+ )
+ ;
+}
+
diff --git a/python/paludis_python.hh b/python/paludis_python.hh
index aacf7beac..640b521bc 100644
--- a/python/paludis_python.hh
+++ b/python/paludis_python.hh
@@ -188,6 +188,7 @@ void expose_mask() PALUDIS_VISIBLE;
void expose_match_package() PALUDIS_VISIBLE;
void expose_metadata_key() PALUDIS_VISIBLE;
void expose_name() PALUDIS_VISIBLE;
+void expose_package_dep_spec_constraint() PALUDIS_VISIBLE;
void expose_package_id() PALUDIS_VISIBLE;
void expose_repository() PALUDIS_VISIBLE;
void expose_selection() PALUDIS_VISIBLE;
diff --git a/python/paludis_python_so.cc b/python/paludis_python_so.cc
index f8b4e3eca..b2ac1804c 100644
--- a/python/paludis_python_so.cc
+++ b/python/paludis_python_so.cc
@@ -37,6 +37,7 @@ BOOST_PYTHON_MODULE(paludis)
expose_fs_path();
expose_contents();
expose_filter(); /* must be before dep_spec */
+ expose_package_dep_spec_constraint();
expose_dep_spec();
expose_dep_label();
expose_name();