6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-13 14:43:03 +00:00

fix: always print plugins sorted by name

`tutor plugins list` used to print plugins in random oredr. To be honest
this has always bothered me.
This commit is contained in:
Régis Behmo 2021-11-01 20:42:23 +01:00 committed by Régis Behmo
parent d9d08ad0f7
commit 485f47f6d0
2 changed files with 5 additions and 1 deletions

View File

@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥".
## Unreleased ## Unreleased
- [Improvement] Make `tutor plugins list` print plugins sorted by name.
- [Improvement] Ignore Python plugins which cannot be loaded. - [Improvement] Ignore Python plugins which cannot be loaded.
## v12.1.6 (2021-11-02) ## v12.1.6 (2021-11-02)

View File

@ -363,11 +363,14 @@ class Plugins:
prevent too many re-computations, which happens a lot. prevent too many re-computations, which happens a lot.
""" """
installed_plugin_names = set() installed_plugin_names = set()
plugins = []
for PluginClass in cls.PLUGIN_CLASSES: for PluginClass in cls.PLUGIN_CLASSES:
for plugin in PluginClass.iter_installed(): for plugin in PluginClass.iter_installed():
if plugin.name not in installed_plugin_names: if plugin.name not in installed_plugin_names:
installed_plugin_names.add(plugin.name) installed_plugin_names.add(plugin.name)
yield plugin plugins.append(plugin)
plugins = sorted(plugins, key=lambda plugin: plugin.name)
yield from plugins
def iter_enabled(self) -> Iterator[BasePlugin]: def iter_enabled(self) -> Iterator[BasePlugin]:
for plugin in self.iter_installed(): for plugin in self.iter_installed():