def on_suggest(self, user_input, items_chain):
    if ((not items_chain) or (items_chain[0].category() != kp.ItemCategory.KEYWORD)):
        return
    suggestions = []
    if (len(items_chain) == 2):
        items = []
        if (not self.current_output):
            for x in range(0, self.max_results):
                try:
                    items.append(str(getattr(self.fakeGenerator, items_chain[1].target())()))
                except Exception as error:
                    items.append(str(error))
                    continue
            if (len(items) > 0):
                items = list(set(items))
                for x in items:
                    self.current_output.append(self.create_item(category=self.ITEMRESULT, label=x, short_desc='Press Enter to copy', target=x, args_hint=kp.ItemArgsHint.FORBIDDEN, hit_hint=kp.ItemHitHint.IGNORE, loop_on_suggest=False))
        suggestions = self.current_output
    else:
        self.current_output = []
        lines = self.load_text_resource('providers.json')
        data = json.loads(lines)
        for item in data:
            try:
                suggestions.append(self.create_item(category=self.ITEMCAT, label=item['name'], short_desc=item['description'], target=item['function'], args_hint=kp.ItemArgsHint.FORBIDDEN, hit_hint=kp.ItemHitHint.IGNORE, icon_handle=self.load_icon('res://{}/icons/{}.png'.format(self.package_full_name(), item['name'][0].upper())), loop_on_suggest=True))
            except Exception as error:
                self.err('Could not generate suggestion for fake data category: {}'.format(item['name']), error)
    self.set_suggestions(suggestions, kp.Match.FUZZY, kp.Sort.DEFAULT)
def on_suggest(self, user_input, items_chain):
    if ((not items_chain) or (items_chain[0].category() != kp.ItemCategory.KEYWORD)):
        return
    suggestions = []
    if (len(items_chain) == 2):
        items = []
        if (not self.current_output):
            for x in range(0, self.max_results):
                try:
                    items.append(str(getattr(self.fakeGenerator, items_chain[1].target())()))
                except Exception as error:
                    items.append(str(error))
                    continue
            if (len(items) > 0):
                items = list(set(items))
                for x in items:
                    self.current_output.append(self.create_item(category=self.ITEMRESULT, label=x, short_desc='Press Enter to copy', target=x, args_hint=kp.ItemArgsHint.FORBIDDEN, hit_hint=kp.ItemHitHint.IGNORE, loop_on_suggest=False))
        suggestions = self.current_output
    else:
        self.current_output = []
        lines = self.load_text_resource('providers.json')
        data = json.loads(lines)
        for item in data:
            try:
                suggestions.append(self.create_item(category=self.ITEMCAT, label=item['name'], short_desc=item['description'], target=item['function'], args_hint=kp.ItemArgsHint.FORBIDDEN, hit_hint=kp.ItemHitHint.IGNORE, icon_handle=self.load_icon('res://{}/icons/{}.png'.format(self.package_full_name(), item['name'][0].upper())), loop_on_suggest=True))
            except Exception as error:
                self.err('Could not generate suggestion for fake data category: {}'.format(item['name']), error)
    self.set_suggestions(suggestions, kp.Match.FUZZY, kp.Sort.DEFAULT)