def parse_routing_rules(routing_config, hostname):
    rules = []
    for prefix, relative_redirects in routing_config.items():
        for postfix, destination in relative_redirects.items():
            destination.setdefault('http_redirect_code', '302')
            destination['protocol'] = 'https'
            if 'hostname' not in destination.keys():
                destination['hostname'] = hostname
                for key in ('replace_key', 'replace_key_prefix'):
                    if key in destination:
                        destination[key] = prefix + destination[key]
            rules.append(RoutingRule.when(
                key_prefix=prefix+postfix,
            ).then_redirect(**destination))

    # Sort the rules in reverse order of prefix to match, so that
    # long-match wins.
    return RoutingRules(
        sorted(rules, key=lambda rule: rule.condition.key_prefix,
               reverse=True)
    )
Parse routing rule description.
dataset/ETHPy150Open ClusterHQ/flocker/admin/release.py/parse_routing_rules