def print_available_plugins() -> None:
existing_packages = set(get_repo_plugins().keys())
def _header(value: str) -> str:
return f'{value}\n{"-" * len(value)}'
installed_plugins = [
(
plugin_cls.__module__, kind, plugin_cls._config.display_name,
plugin_cls._config.namespace, sys.modules[plugin_cls.__module__].__file__
)
for kind, plugin_parent in (('Generic', AbstractPlugin), ('Source', FileResolverPlugin))
for plugin_cls in [v for _, v in sorted(get_installed_plugins(plugin_parent, True).items(), key=lambda v: v[0])]
]
preinstalled_packages = set[Path]()
installed_packages = set[str](module for module, *_ in installed_plugins)
plugins_path = Path(__file__).parent
print(_header('Installed plugins:'))
print(PLUGIN_STRING.format('Package', 'Type', 'Name', 'Namespace', install_from=''))
for *values, module_path in installed_plugins:
if not module_path:
continue
install_path = Path(module_path).parent
if plugins_path == install_path:
preinstalled_packages.add(install_path)
elif (MainWindow.global_plugins_dir in install_path.parents) or (install_path.parent.stem == REPO_NAME):
installed_packages.add(install_path.stem)
for *values, module_path in installed_plugins:
if module_path:
pkg_name = Path(module_path).parent
if pkg_name in preinstalled_packages:
install_from = '*'
elif pkg_name.stem in existing_packages:
install_from = '+'
else:
install_from = '?'
else:
install_from = ' '
print(' ' + PLUGIN_STRING.format(*values, install_from=install_from))
print('\n * => Pre-installed, + => Installed, ? => Custom\n')
external_packages = existing_packages - installed_packages
print(_header('Missing VSPreview Plugins:'))
if not len(external_packages):
print(' None found!')
else:
print(' ' + ', '.join(external_packages))