mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Moving DevtoolsLog object to client.py
This commit is contained in:
@@ -31,8 +31,8 @@ from ._profile import timer
|
|||||||
from .binding import Bindings, NoBinding
|
from .binding import Bindings, NoBinding
|
||||||
from .css.stylesheet import Stylesheet, StylesheetError
|
from .css.stylesheet import Stylesheet, StylesheetError
|
||||||
from .design import ColorSystem
|
from .design import ColorSystem
|
||||||
from .devtools.client import DevtoolsClient, DevtoolsConnectionError
|
from .devtools.client import DevtoolsClient, DevtoolsConnectionError, DevtoolsLog
|
||||||
from .devtools.redirect_output import DevtoolsRedirector, DevtoolsLog
|
from .devtools.redirect_output import DevtoolsRedirector
|
||||||
from .dom import DOMNode
|
from .dom import DOMNode
|
||||||
from .driver import Driver
|
from .driver import Driver
|
||||||
from .file_monitor import FileMonitor
|
from .file_monitor import FileMonitor
|
||||||
|
|||||||
@@ -3,24 +3,40 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
import base64
|
import base64
|
||||||
import datetime
|
import datetime
|
||||||
|
import inspect
|
||||||
import json
|
import json
|
||||||
import pickle
|
import pickle
|
||||||
from asyncio import Queue, Task, QueueFull
|
from asyncio import Queue, Task, QueueFull
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from typing import Type, Any
|
from typing import Type, Any, NamedTuple
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from aiohttp import ClientResponseError, ClientConnectorError, ClientWebSocketResponse
|
from aiohttp import ClientResponseError, ClientConnectorError, ClientWebSocketResponse
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.segment import Segment
|
from rich.segment import Segment
|
||||||
|
|
||||||
from textual.devtools.redirect_output import DevtoolsLog
|
|
||||||
|
|
||||||
DEFAULT_PORT = 8081
|
DEFAULT_PORT = 8081
|
||||||
WEBSOCKET_CONNECT_TIMEOUT = 3
|
WEBSOCKET_CONNECT_TIMEOUT = 3
|
||||||
LOG_QUEUE_MAXSIZE = 512
|
LOG_QUEUE_MAXSIZE = 512
|
||||||
|
|
||||||
|
|
||||||
|
class DevtoolsLog(NamedTuple):
|
||||||
|
"""A devtools log message.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
objects_or_string (tuple[Any, ...]): Corresponds to the data that will
|
||||||
|
ultimately be passed to Console.print in order to generate the log
|
||||||
|
Segments.
|
||||||
|
caller (inspect.FrameInfo): Information about where this log message was
|
||||||
|
created. In other words, where did the user call `print` or `App.log`
|
||||||
|
from. Used to display line number and file name in the devtools window.
|
||||||
|
"""
|
||||||
|
|
||||||
|
objects_or_string: tuple[Any, ...] | str
|
||||||
|
caller: inspect.FrameInfo | None = None
|
||||||
|
|
||||||
|
|
||||||
class DevtoolsConsole(Console):
|
class DevtoolsConsole(Console):
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args, **kwargs) -> None:
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|||||||
@@ -1,28 +1,13 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
from typing import NamedTuple, Any, TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
from textual.devtools.client import DevtoolsLog
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from textual.devtools.client import DevtoolsClient
|
from textual.devtools.client import DevtoolsClient
|
||||||
|
|
||||||
|
|
||||||
class DevtoolsLog(NamedTuple):
|
|
||||||
"""A devtools log message.
|
|
||||||
|
|
||||||
Attributes:
|
|
||||||
objects_or_string (tuple[Any, ...]): Corresponds to the data that will
|
|
||||||
ultimately be passed to Console.print in order to generate the log
|
|
||||||
Segments.
|
|
||||||
caller (inspect.FrameInfo): Information about where this log message was
|
|
||||||
created. In other words, where did the user call `print` or `App.log`
|
|
||||||
from. Used to display line number and file name in the devtools window.
|
|
||||||
"""
|
|
||||||
|
|
||||||
objects_or_string: tuple[Any, ...] | str
|
|
||||||
caller: inspect.FrameInfo | None = None
|
|
||||||
|
|
||||||
|
|
||||||
class DevtoolsRedirector:
|
class DevtoolsRedirector:
|
||||||
"""
|
"""
|
||||||
A file-like object which redirects anything written to it to the devtools instance
|
A file-like object which redirects anything written to it to the devtools instance
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ from . import messages
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .app import App
|
from .app import App
|
||||||
from .screen import Screen
|
|
||||||
|
|
||||||
|
|
||||||
class NoParent(Exception):
|
class NoParent(Exception):
|
||||||
|
|||||||
Reference in New Issue
Block a user