def assign_space(total_size, specs):
    """
    Satisfy all the PartitionSpecs according to their weight.
    In other words, calculate spec.count of all the specs.
    """
    total_weight = 0.0
    for spec in specs:
        total_weight += float(spec.weight)

    for spec in specs:
        num_blocks = int((float(spec.weight) / total_weight) * (total_size / float(spec.size)))
        spec.set_count(num_blocks)
        total_size -= num_blocks * spec.size
        total_weight -= spec.weight
dataset/ETHPy150Open openshift/openshift-ansible/roles/kube_nfs_volumes/library/partitionpool.py/assign_space/original