def file_or_path(file):
is_path = False<EOL>if isinstance(file, string_types):<EOL><INDENT>if not os.path.exists(file):<EOL><INDENT>raise IOError('<STR_LIT>' + file + '<STR_LIT>')<EOL><DEDENT>file = open(file, '<STR_LIT:rb>')<EOL>is_path = True<EOL><DEDENT>return file, is_path<EOL>
Open a file and return the handler if a path is given.
If a file handler is given, return it directly.

:param file: A file handler or path to a file.

:returns: A tuple with the open file handler and whether it was a path.
:rtype: (file, bool)