You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/12/13 02:16:27 UTC

[GitHub] [airflow] turbaszek commented on a change in pull request #13036: Refactor plugins command output using AirflowConsole

turbaszek commented on a change in pull request #13036:
URL: https://github.com/apache/airflow/pull/13036#discussion_r541824087



##########
File path: airflow/cli/commands/plugins_command.py
##########
@@ -78,33 +75,17 @@ def dump_plugins(args):
         print("No plugins loaded")
         return
 
-    console = Console()
-    console.print("[bold yellow]SUMMARY:[/bold yellow]")
-    console.print(
-        f"[bold green]Plugins directory[/bold green]: {conf.get('core', 'plugins_folder')}\n", highlight=False
-    )
-    console.print(
-        f"[bold green]Loaded plugins[/bold green]: {len(plugins_manager.plugins)}\n", highlight=False
-    )
+    plugins_info: List[Dict[str, str]] = []
+    for plugin in plugins_manager.plugins:
+        info = {"name": plugin.name}
+        info.update({n: getattr(plugin, n) for n in PLUGINS_ATTRIBUTES_TO_DUMP})
+        plugins_info.append(info)
 
-    for attr_name in PLUGINS_MANAGER_ATTRIBUTES_TO_DUMP:
-        attr_value: Optional[List[Any]] = getattr(plugins_manager, attr_name)
-        if not attr_value:
-            continue
-        table = SimpleTable(title=attr_name.capitalize().replace("_", " "))
-        table.add_column(width=100)
-        for item in attr_value:  # pylint: disable=not-an-iterable
-            table.add_row(
-                f"- {_get_name(item)}",
-            )
-        console.print(table)
+    # Remove empty info
+    if args.output == "table":  # pylint: disable=too-many-nested-blocks
+        for col in list(plugins_info[0].keys()):  # it will exist as there's at least one plugin

Review comment:
       The list should stay there. It's to make sure we iterate over fixed range - the dict may change over time due to `del` statement. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org