Personal preference again, but this code is a bit hard to understand. To make it more self-documenting, you could extract to a method, say `get_file_name(key)`.