def choose_gist(self, res, options={}):
        # Keep the gists to cache
        if not isinstance(res, list): 
            _gists = res.json()
        else:
            _gists = res
        _gists = sorted(_gists, key=lambda k: k['updated_at'], reverse=True)
        util.add_gists_to_cache(_gists)

        # If no callback command, it will just refresh cache
        if self.callback_command:
            # Show the filenames in the quick panel
            self.items = []
            self.items_property = {}
            for _gist in _gists:
                if not self.include_files:
                    description = _gist["description"]
                    if not description:
                        description = "gist:%s" % _gist["id"]

                    self.items.append(description)
                    self.items_property[description] = {
                        "gist": _gist
                    }
                else:
                    # Get gist description
                    description = _gist["description"]
                    if not description:
                        description = "gist:%s" % _gist["id"]

                    files_number = len(_gist["files"])
                    if files_number > 1:
                        self.items.append(description)

                    # Add gist files to items
                    gist_items_property = []
                    for key, value in _gist["files"].items():
                        if files_number > 1:
                            key = "%s%s" % (" " * 4, key)
                        self.items.append(key)
                        self.items_property[key] = [{
                            "fileName": key.strip(),
                            "fileProperty": value,
                            "gist": _gist
                        }]
                        gist_items_property.extend(self.items_property[key])

                    # Populate items_property
                    self.items_property[description] = gist_items_property

            self.window.show_quick_panel(self.items, self.on_done, 
                sublime.MONOSPACE_FONT)
dataset/ETHPy150Open xjsender/HaoGist/main.py/ChooseGist.choose_gist/original