コード例 #1
0
ファイル: test__ped_ped.py プロジェクト: carlroth/pyparted
    def runTest(self):
        self.assertRaises(TypeError, _ped.constraint_any, None)

        constraint = _ped.constraint_any(self._device)
        self.assertIsInstance(constraint, _ped.Constraint)

        for testGeom in [_ped.Geometry(self._device, 0, 5),
                         _ped.Geometry(self._device, 10, 25),
                         _ped.Geometry(self._device, 0, 100)]:
            self.assertTrue(constraint.is_solution(testGeom))
コード例 #2
0
    def runTest(self):
        self.assertRaises(TypeError, _ped.constraint_any, None)

        constraint = _ped.constraint_any(self._device)
        self.assertIsInstance(constraint, _ped.Constraint)

        for testGeom in [_ped.Geometry(self._device, 0, 5),
                         _ped.Geometry(self._device, 10, 25),
                         _ped.Geometry(self._device, 0, 100)]:
            self.assertTrue(constraint.is_solution(testGeom))
コード例 #3
0
    def __init__(self, *args, **kwargs):
        """Create a new Constraint object.  There are many different ways to
           create a Constraint, all depending on the parameters passed to
           __init__.  If minGeom and maxGeom are supplied, the constraint will
           be created to satisfy both.  If only one of minGeom or maxGeom are
           supplied, the constraint is only guaranteed to solve the given
           paramter.  If exactGeom is given, the constraint will only be
           satisfied by the given geometry.  If device is given, any region
           on that device will satisfy the constraint.

           If none of the previously mentioned parameters are supplied, all of
           startAlign, EndAlign, startRange, endRange, minSize, and maxSize
           must be given."""
        if "PedConstraint" in kwargs:
            self.__constraint = kwargs.get("PedConstraint")
        elif "minGeom" in kwargs and "maxGeom" in kwargs:
            ming = kwargs.get("minGeom").getPedGeometry()
            maxg = kwargs.get("maxGeom").getPedGeometry()
            self.__constraint = _ped.constraint_new_from_min_max(ming, maxg)
        elif "minGeom" in kwargs:
            ming = kwargs.get("minGeom").getPedGeometry()
            self.__constraint = _ped.constraint_new_from_min(ming)
        elif "maxGeom" in kwargs:
            maxg = kwargs.get("maxGeom").getPedGeometry()
            self.__constraint = _ped.constraint_new_from_max(maxg)
        elif "exactGeom" in kwargs:
            exact = kwargs.get("exactGeom").getPedGeometry()
            self.__constraint = _ped.constraint_exact(exact)
        elif "device" in kwargs:
            dev = kwargs.get("device").getPedDevice()
            self.__constraint = _ped.constraint_any(dev)
        elif "startAlign" in kwargs and "endAlign" in kwargs and \
             "startRange" in kwargs and "endRange" in kwargs and \
             "minSize" in kwargs and "maxSize" in kwargs:
            starta = kwargs.get("startAlign").getPedAlignment()
            enda = kwargs.get("endAlign").getPedAlignment()
            startr = kwargs.get("startRange").getPedGeometry()
            endr = kwargs.get("endRange").getPedGeometry()
            mins = kwargs.get("minSize")
            maxs = kwargs.get("maxSize")
            self.__constraint = _ped.Constraint(starta, enda, startr, endr,
                                                mins, maxs)
        else:
            raise parted.ConstraintException(
                "missing initialization parameters")
コード例 #4
0
ファイル: constraint.py プロジェクト: KaneVanguard/pyparted
    def __init__(self, *args, **kwargs):
        """Create a new Constraint object.  There are many different ways to
           create a Constraint, all depending on the parameters passed to
           __init__.  If minGeom and maxGeom are supplied, the constraint will
           be created to satisfy both.  If only one of minGeom or maxGeom are
           supplied, the constraint is only guaranteed to solve the given
           paramter.  If exactGeom is given, the constraint will only be
           satisfied by the given geometry.  If device is given, any region
           on that device will satisfy the constraint.

           If none of the previously mentioned parameters are supplied, all of
           startAlign, EndAlign, startRange, endRange, minSize, and maxSize
           must be given."""
        if kwargs.has_key("PedConstraint"):
            self.__constraint = kwargs.get("PedConstraint")
        elif kwargs.has_key("minGeom") and kwargs.has_key("maxGeom"):
            ming = kwargs.get("minGeom").getPedGeometry()
            maxg = kwargs.get("maxGeom").getPedGeometry()
            self.__constraint = _ped.constraint_new_from_min_max(ming, maxg)
        elif kwargs.has_key("minGeom"):
            ming = kwargs.get("minGeom").getPedGeometry()
            self.__constraint = _ped.constraint_new_from_min(ming)
        elif kwargs.has_key("maxGeom"):
            maxg = kwargs.get("maxGeom").getPedGeometry()
            self.__constraint = _ped.constraint_new_from_max(maxg)
        elif kwargs.has_key("exactGeom"):
            exact = kwargs.get("exactGeom").getPedGeometry()
            self.__constraint = _ped.constraint_exact(exact)
        elif kwargs.has_key("device"):
            dev = kwargs.get("device").getPedDevice()
            self.__constraint = _ped.constraint_any(dev)
        elif kwargs.has_key("startAlign") and kwargs.has_key("endAlign") and \
             kwargs.has_key("startRange") and kwargs.has_key("endRange") and \
             kwargs.has_key("minSize") and kwargs.has_key("maxSize"):
            starta = kwargs.get("startAlign").getPedAlignment()
            enda = kwargs.get("endAlign").getPedAlignment()
            startr = kwargs.get("startRange").getPedGeometry()
            endr = kwargs.get("endRange").getPedGeometry()
            mins = kwargs.get("minSize")
            maxs = kwargs.get("maxSize")
            self.__constraint = _ped.Constraint(starta, enda, startr, endr,
                                                mins, maxs)
        else:
            raise parted.ConstraintException, "missing initialization parameters"