def runTest(self): # Check that not passing args to parted.Alignment.__init__ is caught. self.assertRaises(parted.AlignmentException, parted.Alignment) # And then the correct ways of creating a parted.Alignment a = parted.Alignment(offset=0, grainSize=100) self.assertIsInstance(a, parted.Alignment) b = parted.Alignment(PedAlignment=self.pa) self.assertIsInstance(b, parted.Alignment) # Test for _ped.Alignment equality self.assertEqual(b.getPedAlignment(), self.pa)
def intersect(self, b): """Create and return a new Alignment that describes the intersection of self and alignment b. A sector will satisfy the new alignment iff it satisfies both of the original alignments. Whether a sector satisfies a given alignment is determined by is_aligned().""" return parted.Alignment( PedAlignment=self.__alignment.intersect(b.getPedAlignment()))
def endAlignment(self): if not self._endAlignment: self._endAlignment = parted.Alignment( offset=self.alignment.offset - 1, grainSize=self.alignment.grainSize) return self._endAlignment
def alignment(self): """ Alignment requirements for this device. """ if not self._alignment: try: disklabel_alignment = self.partedDisk.partitionAlignment except _ped.CreateException: disklabel_alignment = parted.Alignment(offset=0, grainSize=1) try: optimum_device_alignment = self.partedDevice.optimumAlignment except _ped.CreateException: optimum_device_alignment = None try: minimum_device_alignment = self.partedDevice.minimumAlignment except _ped.CreateException: minimum_device_alignment = None try: a = optimum_device_alignment.intersect(disklabel_alignment) except (ArithmeticError, AttributeError): try: a = minimum_device_alignment.intersect(disklabel_alignment) except (ArithmeticError, AttributeError): a = disklabel_alignment self._alignment = a return self._alignment
def setUp(self): self.pa = _ped.Alignment(0, 100) self.alignment = parted.Alignment(PedAlignment=self.pa)
def setUp(self): RequiresDevice.setUp(self) self.g = parted.Geometry(device=self.device, start=0, length=100) self.a = parted.Alignment(offset=10, grainSize=0)
def partitionAlignment(self): """Partition start address Alignment.""" alignment = self.__disk.get_partition_alignment() return parted.Alignment(PedAlignment=alignment)