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 2022/03/31 18:49:06 UTC

[GitHub] [airflow] tirkarthi commented on a change in pull request #22588: Print configuration on scheduler startup.

tirkarthi commented on a change in pull request #22588:
URL: https://github.com/apache/airflow/pull/22588#discussion_r839921445



##########
File path: airflow/utils/cli.py
##########
@@ -341,19 +346,30 @@ def _wrapper(*args, **kwargs):
     return cast(T, _wrapper)
 
 
-def get_config_with_source(include_default=False):
+def get_config_with_source(include_default=False, include_colors=True):
     """
     Return configuration along with source for each option.
     """
-    parser = AirflowConfigParser(strict=False, interpolation=None)
     config_dict = conf.as_dict(display_source=True)
 
     with io.StringIO() as buf, redirect_stdout(buf):
         for section, options in config_dict.items():
-            print(f"[{section}]")
-            for key, (value, source) in options.items():
-                if not include_default and source == "default":
-                    continue
-                print(f"{key} = {value} [{source}]")
-            print()
-        return buf.getvalue()
+            if not include_default:
+                options = {
+                    key: (value, source) for key, (value, source) in options.items() if source != "default"
+                }
+
+            # Print the section only when there are options after filtering
+            if options:
+                print(f"[{section}]")
+                for key, (value, source) in options.items():
+                    if not include_default and source == "default":
+                        continue
+                    print(f"{key} = {value} [{source}]")
+                print()
+        code = buf.getvalue()
+
+        if include_colors:
+            code = pygments.highlight(code=code, formatter=get_terminal_formatter(), lexer=IniLexer())

Review comment:
       Thanks, makes sense. Used `is_terminal_support_colors` for highlighting. 




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

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