| 360 | |
| 361 | |
| 362 | class TextInfoOutput(InfoOutputBase): |
| 363 | @classmethod |
| 364 | def protocol(cls) -> str: |
| 365 | return "text" |
| 366 | |
| 367 | def get_feature_status(self, fmt, name, status): |
| 368 | enabled = status.get("enabled", True) |
| 369 | mark = OK if enabled else NOK |
| 370 | description = status.get("description", "Description N/A") |
| 371 | s = {"fg": ("bright_green" if enabled else "bright_red")} |
| 372 | return style(fmt.format(mark=mark, status=status, name=name, enabled=enabled, description=description), **s) |
| 373 | |
| 374 | def output_info_data(self, data): |
| 375 | out = PrettyReport() |
| 376 | |
| 377 | # Left hand side of the table contains logo and basic project information |
| 378 | logo = LOGO.format(version=f'Version {data["aura_version"]}'.center(26)) |
| 379 | |
| 380 | lhs_lines = logo.split("\n") |
| 381 | lhs_size = max(len(x) for x in lhs_lines) + 1 |
| 382 | |
| 383 | #print(logo) |
| 384 | out.print_top_separator() |
| 385 | |
| 386 | # Right hand side lists environment information (installed plugins, URI handlers etc.) |
| 387 | rhs_lines = [] |
| 388 | |
| 389 | if data["schema_validation"] is not None: |
| 390 | semantic = data["schema_validation"]["semantic_rules"] |
| 391 | if semantic is True: |
| 392 | rhs_lines.append(style(f" {OK} Semantic rules configuration is valid", fg="bright_green")) |
| 393 | else: |
| 394 | rhs_lines.append(style(f" {NOK} Semantic rules configuration is not valid:", fg="bright_red")) |
| 395 | rhs_lines.append(semantic) |
| 396 | else: |
| 397 | rhs_lines.append(style(f" ? - `jsonschema` is not installed, unable to verify the configuration", fg="cyan")) |
| 398 | |
| 399 | rhs_lines.append("") |
| 400 | rhs_lines.append("Installed analyzers:") |
| 401 | |
| 402 | for name, i in data["analyzers"].items(): |
| 403 | rhs_lines.append(self.get_feature_status(fmt=" {mark} {name}: {description}", name=name, status=i)) |
| 404 | |
| 405 | rhs_lines.append("Integrations:") |
| 406 | for name, i in data["integrations"].items(): |
| 407 | rhs_lines.append(self.get_feature_status(fmt=" {mark} {name}: {description}", name=name, status=i)) |
| 408 | |
| 409 | rhs_lines.append("Installed URI handlers:") |
| 410 | for name, i in data["uri_handlers"].items(): |
| 411 | rhs_lines.append(self.get_feature_status(fmt=" {mark} `{name}://` - {description}", name=name, status=i)) |
| 412 | |
| 413 | rhs_size = max(len(x) for x in rhs_lines) |
| 414 | |
| 415 | for idx in range(max(len(rhs_lines), len(lhs_lines))): |
| 416 | if idx < len(lhs_lines): |
| 417 | lhs = out._align_text(lhs_lines[idx], lhs_size) |
| 418 | else: |
| 419 | lhs = " "*lhs_size |