@contextlib.contextmanager<EOL>def _open_file_obj(f, mode="<STR_LIT:r>"):
if isinstance(f, six.string_types):<EOL><INDENT>if f.startswith(("<STR_LIT>", "<STR_LIT>")):<EOL><INDENT>file_obj = _urlopen(f)<EOL>yield file_obj<EOL>file_obj.close()<EOL><DEDENT>else:<EOL><INDENT>with open(f, mode) as file_obj:<EOL><INDENT>yield file_obj<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>yield f<EOL><DEDENT>
A context manager that provides access to a file.

:param f: the file to be opened
:type f: a file-like object or path to file
:param mode: how to open the file
:type mode: string