The internal servers have no access to outside package repositories and run Python 3.8/3.9, so the UI moves from hand-drawn curses to Textual 6.2.1 (the last release supporting 3.8.1), vendored with its pure-Python dependencies in vendor/. The launcher puts vendor/ first on sys.path, so a plain checkout runs with no pip and no network. - dsflow/: the single script split into a package (pure moves of the backend sections); action rules moved to ops.py, free of Textual - dsflow/ui/: tabs, detail pane, live sanity-run panel, log viewer, modal dialogs, filter, themes, mouse support - tests/test_ui.py: headless UI tests through Textual's pilot - tools/vendor.py (refresh vendor/), tools/screenshots.py (README images) - README, CLAUDE.md, TODO and the feature doc updated for the new layout, the Python 3.8.1 floor and the vendoring rules Verified: 11 tests green on Python 3.12 and 3.8.20; the shipped file set runs under `python -I -S` on both. Co-Authored-By: Claude Opus 5.5 <[email protected]>
58 lines
1.6 KiB
Python
Vendored
58 lines
1.6 KiB
Python
Vendored
import io
|
|
from typing import IO, TYPE_CHECKING, Any, List
|
|
|
|
from .ansi import AnsiDecoder
|
|
from .text import Text
|
|
|
|
if TYPE_CHECKING:
|
|
from .console import Console
|
|
|
|
|
|
class FileProxy(io.TextIOBase):
|
|
"""Wraps a file (e.g. sys.stdout) and redirects writes to a console."""
|
|
|
|
def __init__(self, console: "Console", file: IO[str]) -> None:
|
|
self.__console = console
|
|
self.__file = file
|
|
self.__buffer: List[str] = []
|
|
self.__ansi_decoder = AnsiDecoder()
|
|
|
|
@property
|
|
def rich_proxied_file(self) -> IO[str]:
|
|
"""Get proxied file."""
|
|
return self.__file
|
|
|
|
def __getattr__(self, name: str) -> Any:
|
|
return getattr(self.__file, name)
|
|
|
|
def write(self, text: str) -> int:
|
|
if not isinstance(text, str):
|
|
raise TypeError(f"write() argument must be str, not {type(text).__name__}")
|
|
buffer = self.__buffer
|
|
lines: List[str] = []
|
|
while text:
|
|
line, new_line, text = text.partition("\n")
|
|
if new_line:
|
|
lines.append("".join(buffer) + line)
|
|
buffer.clear()
|
|
else:
|
|
buffer.append(line)
|
|
break
|
|
if lines:
|
|
console = self.__console
|
|
with console:
|
|
output = Text("\n").join(
|
|
self.__ansi_decoder.decode_line(line) for line in lines
|
|
)
|
|
console.print(output)
|
|
return len(text)
|
|
|
|
def flush(self) -> None:
|
|
output = "".join(self.__buffer)
|
|
if output:
|
|
self.__console.print(output)
|
|
del self.__buffer[:]
|
|
|
|
def fileno(self) -> int:
|
|
return self.__file.fileno()
|