XD-DENG commented on a change in pull request #12704:
URL: https://github.com/apache/airflow/pull/12704#discussion_r532859799



##########
File path: airflow/cli/commands/connection_command.py
##########
@@ -19,78 +19,54 @@
 import json
 import os
 import sys
-from typing import List
+from typing import Any, Dict, List
 from urllib.parse import urlparse, urlunparse
 
-import pygments
 import yaml
-from pygments.lexers.data import YamlLexer
 from sqlalchemy.orm import exc
-from tabulate import tabulate
 
+from airflow.cli.simple_table import AirflowConsole
 from airflow.exceptions import AirflowNotFoundException
 from airflow.hooks.base_hook import BaseHook
 from airflow.models import Connection
 from airflow.utils import cli as cli_utils
-from airflow.utils.cli import should_use_colors
-from airflow.utils.code_utils import get_terminal_formatter
+from airflow.utils.cli import suppress_logs_and_warning
 from airflow.utils.session import create_session
 
 
-def _tabulate_connection(conns: List[Connection], tablefmt: str):
-    tabulate_data = [
-        {
-            'Conn Id': conn.conn_id,
-            'Conn Type': conn.conn_type,
-            'Description': conn.description,
-            'Host': conn.host,
-            'Port': conn.port,
-            'Is Encrypted': conn.is_encrypted,
-            'Is Extra Encrypted': conn.is_encrypted,
-            'Extra': conn.extra,
-        }
-        for conn in conns
-    ]
-
-    msg = tabulate(tabulate_data, tablefmt=tablefmt, headers='keys')
-    return msg
-
-
-def _yamulate_connection(conn: Connection):
-    yaml_data = {
-        'Id': conn.id,
-        'Conn Id': conn.conn_id,
-        'Conn Type': conn.conn_type,
-        'Description': conn.description,
-        'Host': conn.host,
-        'Schema': conn.schema,
-        'Login': conn.login,
-        'Password': conn.password,
-        'Port': conn.port,
-        'Is Encrypted': conn.is_encrypted,
-        'Is Extra Encrypted': conn.is_encrypted,
-        'Extra': conn.extra_dejson,
-        'URI': conn.get_uri(),
+def _connection_mapper(conn: Connection) -> Dict[str, Any]:
+    return {
+        'id': conn.id,
+        'conn_id': conn.conn_id,
+        'conn_type': conn.conn_type,
+        'description': conn.description,
+        'host': conn.host,
+        'schema': conn.schema,
+        'login': conn.login,
+        'password': conn.password,
+        'port': conn.port,
+        'is_encrypted': conn.is_encrypted,
+        'is_extra_encrypted': conn.is_encrypted,
+        'extra_dejson': conn.extra_dejson,
+        'get_uri()': conn.get_uri(),

Review comment:
       We may not want `get_uri()` as a column name in the table, or an 
attribute name in yaml/json.




----------------------------------------------------------------
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:
[email protected]


Reply via email to