'parses the inventory file'

def parse(self, inventory, loader, path, cache=False):

    super(InventoryModule, self).parse(inventory, loader, path)
    try:
        data = self.loader.load_from_file(path)
    except Exception as e:
        raise AnsibleParserError(('Unable    to    parse    %s:    %s' % (to_native(path), to_native(e))))
    if ((not data) or (data.get('plugin') != self.NAME)):
        raise AnsibleParserError(('%s    is    empty    or    not    a    constructed    groups    config    file' % to_native(path)))
    try:
        templar = Templar(loader=loader)
        for host in inventory.hosts:
            hostvars = host.get_vars()
            if (host.name in inventory.cache):
                hostvars = combine_vars(hostvars, inventory.cache[host.name])
            templar.set_available_variables(hostvars)
            for (group_name, expression) in data.get('groups', {}):
                conditional = (u'{%%    if    %s    %%}    True    {%%    else    %%}    False    {%%    endif    %%}' % expression)
                result = templar.template(conditional)
                if (result and bool(result)):
                    inventory.add_group(group_name)
                    inventory.add_child(group_name, host.name)
    except Exception as e:
        raise AnsibleParserError(('failed    to    parse    %s:    %s    ' % (to_native(path), to_native(e))))
