def get_taxes_of_effective_rules(taxing_context, tax_rules):
 matching_rules = (tax_rule for tax_rule in tax_rules if tax_rule.matches(taxing_context))
 grouped_by_override = groupby(matching_rules, attrgetter('override_group'))
 highest_override_group = first(grouped_by_override, (None, []))[1]
 grouped_rules = groupby(highest_override_group, attrgetter('priority'))
 tax_groups = [[rule.tax for rule in rules] for (_, rules) in grouped_rules]
 return tax_groups

def get_taxes_of_effective_rules ( taxing_context , tax_rules ) : matching_rules = ( tax_rule for tax_rule in tax_rules if tax_rule . matches ( taxing_context ) ) grouped_by_override = groupby ( matching_rules , attrgetter ( 'override_group' ) ) highest_override_group = first ( grouped_by_override , ( None , [ ] ) ) [ 1 ] grouped_rules = groupby ( highest_override_group , attrgetter ( 'priority' ) ) tax_groups = [ [ rule . tax for rule in rules ] for ( _ , rules ) in grouped_rules ] return tax_groups
get taxes grouped by priority from effective tax rules .