Exemplo n.º 1
0
 def _format_config(self, linter):
     """Format the config of a `Linter`."""
     text_buffer = StringIO()
     # Only show version information if verbosity is high enough
     if self._verbosity > 0:
         text_buffer.write("==== sqlfluff ====\n")
         config_content = [
             ("sqlfluff", get_package_version()),
             ("python", get_python_version()),
             ("dialect", linter.dialect.name),
             ("verbosity", self._verbosity),
         ]
         text_buffer.write(cli_table(config_content, col_width=25))
         text_buffer.write("\n")
         if linter.config.get("rule_whitelist"):
             text_buffer.write(
                 cli_table(
                     [("rules", ", ".join(
                         linter.config.get("rule_whitelist")))],
                     col_width=41,
                 ))
         if self._verbosity > 1:
             text_buffer.write("== Raw Config:\n")
             text_buffer.write(format_config_vals(
                 linter.config.iter_vals()))
     return text_buffer.getvalue()
Exemplo n.º 2
0
 def _format_config(self, linter: Linter) -> str:
     """Format the config of a `Linter`."""
     text_buffer = StringIO()
     # Only show version information if verbosity is high enough
     if self._verbosity > 0:
         text_buffer.write("==== sqlfluff ====\n")
         config_content = [
             ("sqlfluff", get_package_version()),
             ("python", get_python_version()),
             ("implementation", get_python_implementation()),
             ("verbosity", self._verbosity),
         ]
         if linter.dialect:
             config_content.append(("dialect", linter.dialect.name))
         config_content += linter.templater.config_pairs()
         text_buffer.write(
             self.cli_table(config_content,
                            col_width=30,
                            max_label_width=15))
         text_buffer.write("\n")
         if linter.config.get("rule_allowlist"):
             text_buffer.write(
                 self.cli_table(
                     [("rules", ", ".join(
                         linter.config.get("rule_allowlist")))],
                     col_width=41,
                 ))
         if self._verbosity > 1:
             text_buffer.write("\n== Raw Config:\n")
             text_buffer.write(
                 self.format_config_vals(linter.config.iter_vals()))
     return text_buffer.getvalue()