Maybe more stylistic than performant, but as above, I'd rather see this as something like

"port_%s_rules" % direction