

def interpret_conf_limits(conf, name_prefix, info=None):
    '\n    Parses general parms for rate limits looking for things that\n    start with the provided name_prefix within the provided conf\n    and returns lists for both internal use and for /info\n\n    :param conf: conf dict to parse\n    :param name_prefix: prefix of config parms to look for\n    :param info: set to return extra stuff for /info registration\n    '
    conf_limits = []
    for conf_key in conf:
        if conf_key.startswith(name_prefix):
            cont_size = int(conf_key[len(name_prefix):])
            rate = float(conf[conf_key])
            conf_limits.append((cont_size, rate))
    conf_limits.sort()
    ratelimits = []
    conf_limits_info = list(conf_limits)
    while conf_limits:
        (cur_size, cur_rate) = conf_limits.pop(0)
        if conf_limits:
            (next_size, next_rate) = conf_limits[0]
            slope = ((float(next_rate) - float(cur_rate)) / (next_size - cur_size))

            def new_scope(cur_size, slope, cur_rate):
                return (lambda x: (((x - cur_size) * slope) + cur_rate))
            line_func = new_scope(cur_size, slope, cur_rate)
        else:
            line_func = (lambda x: cur_rate)
        ratelimits.append((cur_size, cur_rate, line_func))
    if (info is None):
        return ratelimits
    else:
        return (ratelimits, conf_limits_info)

dataset/ETHPy150Open openstack/swift/swift/common/middleware/ratelimit.py interpret_conf_limits/original