<commit_before>import logging
from flexget.plugin import register_plugin, add_plugin_validators, get_plugin_by_name, PluginError

log = logging.getLogger('inputs')


class PluginInputs(object):
    """ Allows the same input plugin to be configured multiple times in a feed.

    Example:
      inputs:
        - rss: http://feeda.com
        - rss: http://feedb.com
    """

    def validator(self):
        from flexget import validator
        root = validator.factory()
        inputs = root.accept('list')
        add_plugin_validators(inputs, phase='input', excluded=['inputs'])
        return root

    def on_feed_input(self, feed, config):
        entries = []
        entry_titles = set()
        entry_urls = set()
        for item in config:
            for input_name, input_config in item.iteritems():
                input = get_plugin_by_name(input_name)
                if input.api_ver == 1:
                    raise PluginError('Plugin %s does not support API v2' % input_name)

                method = input.phase_handlers['input']
                try:
                    result = method(feed, input_config)
                except PluginError, e:
                    log.warning('Error during input plugin %s: %s' % (input_name, e))
                    continue
                if not result:
                    log.warning('Input %s did not return anything' % input_name)
                    continue
                for entry in result:
                    if entry['title'] in entry_titles:
                        log.debug('Title `%s` already in entry list, skipping.' % entry['title'])
                        continue
                    urls = ([entry['url']] if entry.get('url') else []) + entry.get('urls', [])
                    if any(url in entry_urls for url in urls):
                        log.debug('URL for `%s` already in entry list, skipping.' % entry['title'])
                        continue
                    entries.append(entry)
                    entry_titles.add(entry['title'])
                    entry_urls.update(urls)
        return entries


register_plugin(PluginInputs, 'inputs', api_ver=2)<commit_msg>Prevent inputs plugin from creating warning level message about no entries produced when not necessary. fix #1704<commit_after>import logging
from flexget.plugin import register_plugin, add_plugin_validators, get_plugin_by_name, PluginError

log = logging.getLogger('inputs')


class PluginInputs(object):
    """ Allows the same input plugin to be configured multiple times in a feed.

    Example:
      inputs:
        - rss: http://feeda.com
        - rss: http://feedb.com
    """

    def validator(self):
        from flexget import validator
        root = validator.factory()
        inputs = root.accept('list')
        add_plugin_validators(inputs, phase='input', excluded=['inputs'])
        return root

    def on_feed_input(self, feed, config):
        entries = []
        entry_titles = set()
        entry_urls = set()
        for item in config:
            for input_name, input_config in item.iteritems():
                input = get_plugin_by_name(input_name)
                if input.api_ver == 1:
                    raise PluginError('Plugin %s does not support API v2' % input_name)

                method = input.phase_handlers['input']
                try:
                    result = method(feed, input_config)
                except PluginError, e:
                    log.warning('Error during input plugin %s: %s' % (input_name, e))
                    continue
                if not result:
                    msg = 'Input %s did not return anything' % input_name
                    if feed.no_entries_ok:
                        log.verbose(msg)
                    else:
                        log.warning(msg)
                    continue
                for entry in result:
                    if entry['title'] in entry_titles:
                        log.debug('Title `%s` already in entry list, skipping.' % entry['title'])
                        continue
                    urls = ([entry['url']] if entry.get('url') else []) + entry.get('urls', [])
                    if any(url in entry_urls for url in urls):
                        log.debug('URL for `%s` already in entry list, skipping.' % entry['title'])
                        continue
                    entries.append(entry)
                    entry_titles.add(entry['title'])
                    entry_urls.update(urls)
        return entries


register_plugin(PluginInputs, 'inputs', api_ver=2)
{'fraction_non_alphanumeric': 0.09462412587412587, 'fraction_numerical': 0.0021853146853146855, 'mean_word_length': 1.6750438340151959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6251334', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1144, 'n_words': 335}