def load(file, use_yaml=None):
if isinstance(file, str):<EOL><INDENT>fp = open(file)<EOL>filename = file<EOL><DEDENT>else:<EOL><INDENT>fp = file<EOL>filename = getattr(fp, '<STR_LIT:name>', '<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>return loads(fp.read(), use_yaml, filename)<EOL><DEDENT>except Exception as e:<EOL><INDENT>e.args = ('<STR_LIT>', filename) + e.args<EOL>raise<EOL><DEDENT>
Loads not only JSON files but also YAML files ending in .yml.

:param file: a filename or file handle to read from
:returns: the data loaded from the JSON or YAML file
:rtype: dict