Skip to content

Inspector

inspector

Collection inspector using Textual TUI.

CollectionInspectorApp

CollectionInspectorApp(*, data: Sequence[Dict[str, Any]], collection_name: str = 'collection')

Bases: App[None]

Textual app for inspecting collections.

Initialize the collection inspector application.

Parameters:

Name Type Description Default
data Sequence[Dict[str, Any]]

Sequence of JSON-serializable dictionaries to inspect.

required
collection_name str

Display name for the collection shown in the title and status bar.

'collection'
Source code in t3api_utils/inspector/app.py
def __init__(self, *, data: Sequence[Dict[str, Any]], collection_name: str = "collection") -> None:
    """Initialize the collection inspector application.

    Args:
        data: Sequence of JSON-serializable dictionaries to inspect.
        collection_name: Display name for the collection shown in the
            title and status bar.
    """
    super().__init__()
    self.original_data = list(data)
    self.filtered_data = list(data)
    self.current_index = 0
    self.collection_name = collection_name
    self.search_query = ""

compose

compose() -> ComposeResult

Create the app layout.

Source code in t3api_utils/inspector/app.py
def compose(self) -> ComposeResult:
    """Create the app layout."""
    yield Header()

    with Container(id="main-container"):
        yield StatusBar(self.collection_name, id="status")

        yield SearchBar(id="search-bar")

        with Container(id="content-area"):
            yield JSONViewer(id="json-viewer")

    yield Footer()

on_mount

on_mount() -> None

Initialize the app when mounted.

Source code in t3api_utils/inspector/app.py
def on_mount(self) -> None:
    """Initialize the app when mounted."""
    self.title = f"Collection Inspector: {self.collection_name}"
    self.sub_title = f"{len(self.filtered_data)} objects"
    self._update_display()

action_previous

action_previous() -> None

Navigate to previous object.

Source code in t3api_utils/inspector/app.py
def action_previous(self) -> None:
    """Navigate to previous object."""
    if self.filtered_data and self.current_index > 0:
        self.current_index -= 1
        self._update_display()

action_next

action_next() -> None

Navigate to next object.

Source code in t3api_utils/inspector/app.py
def action_next(self) -> None:
    """Navigate to next object."""
    if self.filtered_data and self.current_index < len(self.filtered_data) - 1:
        self.current_index += 1
        self._update_display()

action_first

action_first() -> None

Navigate to first object.

Source code in t3api_utils/inspector/app.py
def action_first(self) -> None:
    """Navigate to first object."""
    if self.filtered_data:
        self.current_index = 0
        self._update_display()

action_last

action_last() -> None

Navigate to last object.

Source code in t3api_utils/inspector/app.py
def action_last(self) -> None:
    """Navigate to last object."""
    if self.filtered_data:
        self.current_index = len(self.filtered_data) - 1
        self._update_display()

action_clear

action_clear() -> None

Clear search filter.

Source code in t3api_utils/inspector/app.py
def action_clear(self) -> None:
    """Clear search filter."""
    search_input = self.query_one("#search-input", Input)
    search_input.value = ""
    self._apply_search_filter(query="")
    status_bar = self.query_one("#status", StatusBar)
    status_bar.set_search("", len(self.filtered_data))
action_focus_search() -> None

Focus the search input.

Source code in t3api_utils/inspector/app.py
def action_focus_search(self) -> None:
    """Focus the search input."""
    search_input = self.query_one("#search-input", Input)
    search_input.focus()

action_help

action_help() -> None

Show help information.

Source code in t3api_utils/inspector/app.py
def action_help(self) -> None:
    """Show help information."""
    help_text = """ℹ Navigation: ←/→-Previous/Next Home/End-First/Last Ctrl+C-Clear /-Search ?-Help q/Esc-Quit. Use search bar to filter data."""
    self.notify(help_text, severity="information")

on_search_changed

on_search_changed(event: Changed) -> None

Handle search input changes.

Parameters:

Name Type Description Default
event Changed

The Input.Changed event containing the new search value.

required
Source code in t3api_utils/inspector/app.py
@on(Input.Changed, "#search-input")
def on_search_changed(self, event: Input.Changed) -> None:
    """Handle search input changes.

    Args:
        event: The Input.Changed event containing the new search value.
    """
    self._apply_search_filter(query=event.value)
    status_bar = self.query_one("#status", StatusBar)
    status_bar.set_search(self.search_query, len(self.filtered_data))

inspect_collection

inspect_collection(*, data: Sequence[Dict[str, Any]], collection_name: str = 'collection') -> None

Launch the Textual collection inspector.

Parameters:

Name Type Description Default
data Sequence[Dict[str, Any]]

Sequence of JSON-serializable dictionaries to inspect. If empty, prints an info message and returns immediately.

required
collection_name str

Display name for the collection shown in the title and status bar.

'collection'
Source code in t3api_utils/inspector/app.py
def inspect_collection(*, data: Sequence[Dict[str, Any]], collection_name: str = "collection") -> None:
    """Launch the Textual collection inspector.

    Args:
        data: Sequence of JSON-serializable dictionaries to inspect.
            If empty, prints an info message and returns immediately.
        collection_name: Display name for the collection shown in the
            title and status bar.
    """
    if not data:
        print_info("No data to inspect")
        return

    app = CollectionInspectorApp(data=data, collection_name=collection_name)
    app.run()