Refactor file argument parsing in python script