def load_file(filename,<EOL>file_type='<STR_LIT>',<EOL>klazz=YapconfError,<EOL>open_kwargs=None,<EOL>load_kwargs=None):
_check_file_type(file_type, klazz)<EOL>open_kwargs = open_kwargs or {'<STR_LIT>': '<STR_LIT:utf-8>'}<EOL>load_kwargs = load_kwargs or {}<EOL>data = None<EOL>with open(filename, **open_kwargs) as conf_file:<EOL><INDENT>if str(file_type).lower() == '<STR_LIT>':<EOL><INDENT>data = json.load(conf_file, **load_kwargs)<EOL><DEDENT>elif str(file_type).lower() == '<STR_LIT>':<EOL><INDENT>data = yaml.safe_load(conf_file.read())<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError('<STR_LIT>'<EOL>'<STR_LIT>' % file_type)<EOL><DEDENT><DEDENT>if not isinstance(data, dict):<EOL><INDENT>raise klazz('<STR_LIT>'<EOL>'<STR_LIT>' % filename)<EOL><DEDENT>return data<EOL>
Load a file with the given file type.

    Args:
        filename (str): The filename to load.
        file_type (str, optional): Defaults to 'json'. The file type for the
        given filename. Supported types are ``yapconf.FILE_TYPES```
        klazz (optional): The custom exception to raise if something goes
        wrong.
        open_kwargs (dict, optional): Keyword arguments for the open call.
        load_kwargs (dict, optional): Keyword arguments for the load call.

    Raises:
        klazz: If no klazz was passed in, this will be the ``YapconfError``

    Returns:
        dict: The dictionary from the file.