Add _apply_case_modes method to formatting.py

Adds method to remove duplicate code

Also remove redundant copies of modes from action to action

Format formatting.py with PEP8 (just spacing changes)