def any_option_getter(model):
    get_cost = cost_getter(model.get_option)
    get_cost_pd = cost_getter(model.get_option, 'costs_per_distance')

    def get_any_option(option):
        if 'costs.' in option:
            y, rest, k, cost = option.split('.')
            return get_cost(cost, y, k)
        elif 'costs_per_distance.' in option:
            y, rest, k, cost = option.split('.')
            return get_cost_pd(cost, y, k)
        else:
            return model.get_option(option)
    return get_any_option
Get any option from the given Model or SolutionModel, including
dataset/ETHPy150Open calliope-project/calliope/calliope/utils.py/any_option_getter