def weighted_parts(self): try: return self.parts * self.replicas / \ sum(d['weight'] for d in self.devs if d is not None) except ZeroDivisionError: raise exceptions.EmptyRingError('There are no devices in this ' 'ring, or all devices have been ' 'deleted')
def weight_of_one_part(self): """ Returns the weight of each partition as calculated from the total weight of all the devices. """ try: return self.parts * self.replicas / \ sum(d['weight'] for d in self._iter_devs()) except ZeroDivisionError: raise exceptions.EmptyRingError('There are no devices in this ' 'ring, or all devices have been ' 'deleted')