aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-01 20:57:52 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 08:32:59 +0100
commitf243a4014b98275a3ebb7872faadab5ba1fcafa8 (patch)
tree83724be5fe7feb82875e82a8cf4707d1e85cc929 /python
parentf0df32fb13ae4f2d9e78fa914a374da252a3ee52 (diff)
downloadpaludis-f243a4014b98275a3ebb7872faadab5ba1fcafa8.tar.gz
paludis-f243a4014b98275a3ebb7872faadab5ba1fcafa8.tar.xz
key requirements to constraints
Diffstat (limited to 'python')
-rw-r--r--python/dep_spec.cc18
-rw-r--r--python/dep_spec.hh1
-rw-r--r--python/package_dep_spec_constraint.cc29
3 files changed, 48 insertions, 0 deletions
diff --git a/python/dep_spec.cc b/python/dep_spec.cc
index ab05cfb12..beb8fa09a 100644
--- a/python/dep_spec.cc
+++ b/python/dep_spec.cc
@@ -83,6 +83,7 @@ namespace paludis
std::shared_ptr<const InRepositoryConstraint> in_repository;
std::shared_ptr<const FromRepositoryConstraint> from_repository;
std::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements;
+ std::shared_ptr<const KeyConstraintSequence> all_keys;
const std::string str;
Imp(
@@ -96,6 +97,7 @@ namespace paludis
const std::shared_ptr<const InRepositoryConstraint> & ri,
const std::shared_ptr<const FromRepositoryConstraint> & rf,
const std::shared_ptr<const AdditionalPackageDepSpecRequirements> & u,
+ const std::shared_ptr<const KeyConstraintSequence> & k,
const std::string & st) :
package_name_constraint(q),
category_name_part_constraint(c),
@@ -107,6 +109,7 @@ namespace paludis
in_repository(ri),
from_repository(rf),
additional_requirements(u),
+ all_keys(k),
str(st)
{
}
@@ -236,6 +239,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PackageDepSpec & p) :
p.in_repository_constraint(),
p.from_repository_constraint(),
p.additional_requirements_ptr(),
+ p.all_key_constraints(),
stringify(p))
{
if (p.version_requirements_ptr())
@@ -258,6 +262,7 @@ PythonPackageDepSpec::PythonPackageDepSpec(const PythonPackageDepSpec & p) :
p.in_repository_constraint(),
p.from_repository_constraint(),
p.additional_requirements_ptr(),
+ p.all_key_constraints(),
p.py_str())
{
std::copy(p.version_requirements_ptr()->begin(), p.version_requirements_ptr()->end(),
@@ -302,6 +307,13 @@ PythonPackageDepSpec::operator PackageDepSpec() const
p.additional_requirement(*i);
}
+ if (all_key_constraints())
+ {
+ for (auto i(all_key_constraints()->begin()), i_end(all_key_constraints()->end()) ;
+ i != i_end ; ++i)
+ p.key_constraint((*i)->key(), (*i)->operation(), (*i)->pattern());
+ }
+
if (version_requirements_ptr())
{
for (VersionRequirements::ConstIterator i(version_requirements_ptr()->begin()),
@@ -384,6 +396,12 @@ PythonPackageDepSpec::additional_requirements_ptr() const
return _imp->additional_requirements;
}
+const std::shared_ptr<const KeyConstraintSequence>
+PythonPackageDepSpec::all_key_constraints() const
+{
+ return _imp->all_keys;
+}
+
std::string
PythonPackageDepSpec::py_str() const
{
diff --git a/python/dep_spec.hh b/python/dep_spec.hh
index d53d4ebc0..07f89867e 100644
--- a/python/dep_spec.hh
+++ b/python/dep_spec.hh
@@ -179,6 +179,7 @@ namespace paludis
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;
diff --git a/python/package_dep_spec_constraint.cc b/python/package_dep_spec_constraint.cc
index c78ba4127..7385ec2e1 100644
--- a/python/package_dep_spec_constraint.cc
+++ b/python/package_dep_spec_constraint.cc
@@ -46,6 +46,12 @@ class class_package_dep_spec_constraint :
void expose_package_dep_spec_constraint()
{
/**
+ * Enums
+ */
+ enum_auto("KeyConstraintOperation", last_kco,
+ "The operation for a KeyConstraint");
+
+ /**
* PackageDepSpecConstraint
*/
bp::register_ptr_to_python<std::shared_ptr<const PackageDepSpecConstraint> >();
@@ -220,5 +226,28 @@ void expose_package_dep_spec_constraint()
"[RO] The slot name"
)
;
+
+ /**
+ * KeyConstraint
+ */
+ class_package_dep_spec_constraint<KeyConstraint>
+ (
+ "KeyConstraint",
+ "A [.key=value] constraint for a PackageDepSpec.",
+ bp::no_init
+ )
+
+ .add_property("key", &KeyConstraint::key,
+ "[RO] The key"
+ )
+
+ .add_property("pattern", &KeyConstraint::pattern,
+ "[RO] The pattern"
+ )
+
+ .add_property("operation", &KeyConstraint::operation,
+ "[RO] The operation"
+ )
+ ;
}