|
3 | 3 | import asyncio |
4 | 4 | from pathlib import Path |
5 | 5 |
|
6 | | -from rich.console import Console, ConsoleRenderable |
| 6 | +from rich.console import ConsoleRenderable |
7 | 7 | from rich.text import Text |
8 | | -from rich.traceback import Traceback |
9 | 8 | from textual import on |
10 | 9 | from textual.app import ComposeResult |
11 | 10 | from textual.binding import Binding |
@@ -45,51 +44,9 @@ class SetupLog(RichLog): |
45 | 44 | Binding("enter", "continue", show=False), |
46 | 45 | ] |
47 | 46 |
|
48 | | - def __init__( |
49 | | - self, |
50 | | - *args, |
51 | | - non_interactive: bool = False, |
52 | | - **kwargs, |
53 | | - ) -> None: |
| 47 | + def __init__(self, *args, **kwargs) -> None: |
54 | 48 | super().__init__(*args, **kwargs) |
55 | 49 | self._continue = asyncio.Event() |
56 | | - self._non_interactive = non_interactive |
57 | | - self._stdout_console: Console | None = None |
58 | | - if self._non_interactive: |
59 | | - self._stdout_console = Console(force_terminal=True) |
60 | | - |
61 | | - def _write_to_stdout(self, content: object) -> None: |
62 | | - """Write content to stdout via Rich Console.""" |
63 | | - if self._stdout_console is None: |
64 | | - return |
65 | | - try: |
66 | | - if isinstance(content, (str, Text, Traceback)): |
67 | | - self._stdout_console.print(content) |
68 | | - elif isinstance(content, Exception): |
69 | | - self._stdout_console.print(f"[red]Error: {content}[/red]") |
70 | | - self._stdout_console.print_exception() |
71 | | - else: |
72 | | - self._stdout_console.print(content) |
73 | | - except Exception: |
74 | | - pass |
75 | | - |
76 | | - def write( |
77 | | - self, |
78 | | - content: object, |
79 | | - width: int | None = None, |
80 | | - expand: bool = False, |
81 | | - shrink: bool = True, |
82 | | - scroll_end: bool | None = None, |
83 | | - ) -> SetupLog: |
84 | | - """Write content to the log and optionally to stdout.""" |
85 | | - # Always write to the RichLog widget |
86 | | - super().write(content, width=width, expand=expand, shrink=shrink, scroll_end=scroll_end) |
87 | | - |
88 | | - # Write to stdout if non-interactive mode |
89 | | - if self._non_interactive: |
90 | | - self._write_to_stdout(content) |
91 | | - |
92 | | - return self |
93 | 50 |
|
94 | 51 | async def wait_continue(self) -> None: |
95 | 52 | """ |
|
0 commit comments