def run(self, lib, opts, args):

        file_path = opts.output
        file_format = self.config['default_format'].get(str)
        file_mode = 'a' if opts.append else 'w'
        format_options = self.config[file_format]['formatting'].get(dict)

        export_format = ExportFormat.factory(
            file_format, **{
                'file_path': file_path,
                'file_mode': file_mode
            }
        )

        items = []
        data_collector = library_data if opts.library else tag_data

        included_keys = []
        for keys in opts.included_keys:
            included_keys.extend(keys.split(','))
        key_filter = make_key_filter(included_keys)

        for data_emitter in data_collector(lib, ui.decargs(args)):
            try:
                data, item = data_emitter()
            except (mediafile.UnreadableFileError, __HOLE__) as ex:
                self._log.error(u'cannot read file: {0}', ex)
                continue

            data = key_filter(data)
            items += [data]

        export_format.export(items, **format_options)
dataset/ETHPy150Open beetbox/beets/beetsplug/export.py/ExportPlugin.run