def func(self, lib, opts, args):
        """Command handler for the metasync function.
        """
        pretend = opts.pretend
        query = ui.decargs(args)

        sources = []
        for source in opts.sources:
            sources.extend(source.split(','))

        sources = sources or self.config['source'].as_str_seq()

        meta_source_instances = {}
        items = lib.items(query)

        # Avoid needlessly instantiating meta sources (can be expensive)
        if not items:
            self._log.info(u'No items found matching query')
            return

        # Instantiate the meta sources
        for player in sources:
            try:
                cls = META_SOURCES[player]
            except __HOLE__:
                self._log.error(u'Unknown metadata source \'{0}\''.format(
                    player))

            try:
                meta_source_instances[player] = cls(self.config, self._log)
            except (ImportError, ConfigValueError) as e:
                self._log.error(u'Failed to instantiate metadata source '
                                u'\'{0}\': {1}'.format(player, e))

        # Avoid needlessly iterating over items
        if not meta_source_instances:
            self._log.error(u'No valid metadata sources found')
            return

        # Sync the items with all of the meta sources
        for item in items:
            for meta_source in meta_source_instances.values():
                meta_source.sync_from_source(item)

            changed = ui.show_model_changes(item)

            if changed and not pretend:
                item.store()
dataset/ETHPy150Open beetbox/beets/beetsplug/metasync/__init__.py/MetaSyncPlugin.func