Dump data given to file or stdout in file_type.

    Args:
        data (dict): The dictionary to dump.
        filename (str, optional): Defaults to None. The filename to write
        the data to. If none is provided, it will be written to STDOUT.
        file_type (str, optional): Defaults to 'json'. Can be any of
        yapconf.FILE_TYPES
        klazz (optional): Defaults to YapconfError a special error to throw
        when something goes wrong.
        open_kwargs (dict, optional): Keyword arguments to open.
        dump_kwargs (dict, optional): Keyword arguments to dump.

def dump_data(data,
              filename=None,
              file_type='json',
              klazz=YapconfError,
              open_kwargs=None,
              dump_kwargs=None):
    """Dump data given to file or stdout in file_type.

    Args:
        data (dict): The dictionary to dump.
        filename (str, optional): Defaults to None. The filename to write
        the data to. If none is provided, it will be written to STDOUT.
        file_type (str, optional): Defaults to 'json'. Can be any of
        yapconf.FILE_TYPES
        klazz (optional): Defaults to YapconfError a special error to throw
        when something goes wrong.
        open_kwargs (dict, optional): Keyword arguments to open.
        dump_kwargs (dict, optional): Keyword arguments to dump.
    """

    _check_file_type(file_type, klazz)

    open_kwargs = open_kwargs or {'encoding': 'utf-8'}
    dump_kwargs = dump_kwargs or {}

    if filename:
        with open(filename, 'w', **open_kwargs) as conf_file:
            _dump(data, conf_file, file_type, **dump_kwargs)
    else:
        _dump(data, sys.stdout, file_type, **dump_kwargs)