/** * Return a constraint that requires a region to entirely contain \p min. * * \return \c NULL on failure. */ PedConstraint* ped_constraint_new_from_min (const PedGeometry* min) { PedGeometry full_dev; PED_ASSERT (min != NULL); ped_geometry_init (&full_dev, min->dev, 0, min->dev->length); return ped_constraint_new_from_min_max (min, &full_dev); }
/* 1:1 function mappings for constraint.h in libparted */ PyObject *py_ped_constraint_new_from_min_max(PyObject *s, PyObject *args) { PyObject *in_min = NULL, *in_max = NULL; PedGeometry *out_min = NULL, *out_max = NULL; PedConstraint *constraint = NULL; _ped_Constraint *ret = NULL; if (!PyArg_ParseTuple(args, "O!O!", &_ped_Geometry_Type_obj, &in_min, &_ped_Geometry_Type_obj, &in_max)) { return NULL; } out_min = _ped_Geometry2PedGeometry(in_min); if (out_min == NULL) { return NULL; } out_max = _ped_Geometry2PedGeometry(in_max); if (out_max == NULL) { return NULL; } /* ped_constraint_new_from_min_max will ASSERT if this isn't enforced. */ if (!ped_geometry_test_inside(out_max, out_min)) { PyErr_SetString(CreateException, "min geometry must be contained within max geometry"); return NULL; } constraint = ped_constraint_new_from_min_max(out_min, out_max); if (constraint) { ret = PedConstraint2_ped_Constraint(constraint); } else { PyErr_SetString(CreateException, "Could not create new constraint from min/max"); return NULL; } ped_constraint_destroy(constraint); return (PyObject *) ret; }