Esempio n. 1
0
    def _list_plugins(self, print_available=False):
        """Print a list of installed & available plugins"""
        table_rows = []
        table_headers = ["Type", "Name"]
        installed_mark = ' ' * (len('Installed') / 2) + '*'

        plugins_dict = \
            self.plugin_manager.get_all_plugins() \
            if print_available \
            else self.plugin_manager.get_installed_plugins()

        for plugins_type, plugins in plugins_dict.iteritems():
            installed_plugins_list = \
                self.plugin_manager.get_installed_plugins(plugins_type).keys()
            plugins_names = plugins.keys()
            plugins_names.sort()

            if print_available:
                all_plugins_list = []
                for plugin_name in plugins_names:
                    all_plugins_list.append(plugin_name)
                installed_plugins_mark_list = \
                    [installed_mark if plugin_name in installed_plugins_list
                     else '' for plugin_name in all_plugins_list]

                plugins_descs = \
                    [PLUGINS_REGISTRY.get(plugin, {}).get('desc', '')
                     for plugin in all_plugins_list]

                table_rows.append([
                    plugins_type,
                    '\n'.join(all_plugins_list),
                    '\n'.join(installed_plugins_mark_list),
                    '\n'.join(plugins_descs)])
            else:
                table_rows.append([
                    plugins_type,
                    '\n'.join(installed_plugins_list)])

        if print_available:
            table_headers.append("Installed")
            table_headers.append("Description")

        print fancy_table(table_headers, *table_rows)
Esempio n. 2
0
    def _list_plugins(self, print_available=False):
        """Print a list of installed & available plugins"""
        table_rows = []
        table_headers = ["Type", "Name"]
        installed_mark = ' ' * (len('Installed') / 2) + '*'

        plugins_dict = \
            self.plugin_manager.get_all_plugins() \
            if print_available \
            else self.plugin_manager.get_installed_plugins()

        for plugins_type, plugins in plugins_dict.iteritems():
            installed_plugins_list = \
                self.plugin_manager.get_installed_plugins(plugins_type).keys()
            plugins_names = plugins.keys()
            plugins_names.sort()

            if print_available:
                all_plugins_list = []
                for plugin_name in plugins_names:
                    all_plugins_list.append(plugin_name)
                installed_plugins_mark_list = \
                    [installed_mark if plugin_name in installed_plugins_list
                     else '' for plugin_name in all_plugins_list]

                plugins_descs = \
                    [PLUGINS_REGISTRY.get(plugin, {}).get('desc', '')
                     for plugin in all_plugins_list]

                table_rows.append([
                    plugins_type,
                    '\n'.join(all_plugins_list),
                    '\n'.join(installed_plugins_mark_list),
                    '\n'.join(plugins_descs)])
            else:
                table_rows.append([
                    plugins_type,
                    '\n'.join(installed_plugins_list)])

        if print_available:
            table_headers.append("Installed")
            table_headers.append("Description")

        print fancy_table(table_headers, *table_rows)