def cores_to_list(cores):
    """Parse comma-seperated list of core ids into an array. Ranges are
    expanded.
    """
    total = []
    cores = cores.split(',')
    for subcores in cores:
        # expand ranges
        subcores = subcores.partition('-')
        if subcores[1] == '-':
            total += range(int(subcores[0]), int(subcores[2]) + 1)
        else:
            total.append(int(subcores[0]))

    return total