'Generate or update inventory for the source provided'

def parse_source(self, source, cache=True):

    parsed = False
    display.debug((u'Examining    possible    inventory    source:    %s' % source))
    b_source = to_bytes(source)
    if os.path.isdir(b_source):
        display.debug((u'Searching    for    inventory    files    in    directory:    %s' % source))
        for i in sorted(os.listdir(b_source)):
            display.debug((u'Considering    %s' % i))
            if IGNORED.search(i):
                continue
            fullpath = os.path.join(b_source, i)
            parsed_this_one = self.parse_source(to_text(fullpath))
            display.debug((u'parsed    %s    as    %s' % (fullpath, parsed_this_one)))
            if (not parsed):
                parsed = parsed_this_one
    else:
        self._inventory.current_source = source
        if (not self._inventory_plugins):
            self._setup_inventory_plugins()
        failures = []
        for plugin in self._inventory_plugins:
            plugin_name = to_text(getattr(plugin, '_load_name', getattr(plugin, '_original_path', '')))
            display.debug((u'Attempting    to    use    plugin    %s' % plugin_name))
            if plugin.verify_file(source):
                try:
                    plugin.parse(self._inventory, self._loader, source, cache=cache)
                    parsed = True
                    display.vvv((u'Parsed    %s    inventory    source    with    %s    plugin' % (to_text(source), plugin_name)))
                    break
                except AnsibleParserError as e:
                    failures.append((u'\n*    Failed    to    parse    %s    with    %s    inventory    plugin:    %s\n' % (to_text(source), plugin_name, to_text(e))))
            else:
                display.debug((u'%s    did    not    meet    %s    requirements' % (to_text(source), plugin_name)))
        else:
            if failures:
                for fail in failures:
                    display.warning(fail)
    if (not parsed):
        display.warning((u'Unable    to    parse    %s    as    an    inventory    source' % to_text(source)))
    self._inventory.current_source = None
    return parsed
