def display_output(data, out=None, opts=None):
    '''
    Print the passed data using the desired output
    '''
    if opts is None:
        opts = {}
    display_data = try_printout(data, out, opts)

    output_filename = opts.get('output_file', None)
    log.trace('data = {0}'.format(data))
    try:
        # output filename can be either '' or None
        if output_filename:
            with salt.utils.fopen(output_filename, 'a') as ofh:
                fdata = display_data
                if isinstance(fdata, six.text_type):
                    try:
                        fdata = fdata.encode('utf-8')
                    except (__HOLE__, UnicodeEncodeError):
                        # try to let the stream write
                        # even if we didn't encode it
                        pass
                ofh.write(fdata)
                ofh.write('\n')
            return
        if display_data:
            print_cli(display_data)
    except IOError as exc:
        # Only raise if it's NOT a broken pipe
        if exc.errno != errno.EPIPE:
            raise exc
dataset/ETHPy150Open saltstack/salt/salt/output/__init__.py/display_output