Skip to content

Index

appimage_updater.ui.output

Output system for AppImage Updater.

This module provides a pluggable output system with support for multiple formats including Rich console output, plain text, JSON, and HTML.

OutputFormat

Supported output formats.

HTML = 'html' class-attribute instance-attribute

JSON = 'json' class-attribute instance-attribute

PLAIN = 'plain' class-attribute instance-attribute

RICH = 'rich' class-attribute instance-attribute

OutputFormatter

Protocol defining the output formatter interface.

This protocol defines the common interface that all output formatters must implement. Different formatters can provide format-specific implementations while maintaining a consistent API.

end_section()

End the current output section.

Source code in src/appimage_updater/ui/output/interface.py
def end_section(self) -> None:
    """End the current output section."""
    ...

finalize()

Finalize output and return content if applicable.

For formats like JSON and HTML, this returns the complete formatted output. For console formats, this returns None.

Returns:

Type Description
str | None

Complete formatted output or None for console formats

Source code in src/appimage_updater/ui/output/interface.py
def finalize(self) -> str | None:
    """Finalize output and return content if applicable.

    For formats like JSON and HTML, this returns the complete
    formatted output. For console formats, this returns None.

    Returns:
        Complete formatted output or None for console formats
    """
    ...

print(message, **kwargs)

Print a message with optional styling.

Parameters:

Name Type Description Default
message str

The message to print

required
**kwargs Any

Format-specific styling options

{}
Source code in src/appimage_updater/ui/output/interface.py
def print(self, message: str, **kwargs: Any) -> None:
    """Print a message with optional styling.

    Args:
        message: The message to print
        **kwargs: Format-specific styling options
    """
    ...

print_application_list(applications)

Display application list.

Parameters:

Name Type Description Default
applications list[dict[str, Any]]

List of application dictionaries

required
Source code in src/appimage_updater/ui/output/interface.py
def print_application_list(self, applications: list[dict[str, Any]]) -> None:
    """Display application list.

    Args:
        applications: List of application dictionaries
    """
    ...

print_check_results(results)

Display check results in format-appropriate way.

Parameters:

Name Type Description Default
results list[dict[str, Any]]

List of check result dictionaries

required
Source code in src/appimage_updater/ui/output/interface.py
def print_check_results(self, results: list[dict[str, Any]]) -> None:
    """Display check results in format-appropriate way.

    Args:
        results: List of check result dictionaries
    """
    ...

print_config_settings(settings)

Display configuration settings.

Parameters:

Name Type Description Default
settings dict[str, Any]

Dictionary of configuration settings

required
Source code in src/appimage_updater/ui/output/interface.py
def print_config_settings(self, settings: dict[str, Any]) -> None:
    """Display configuration settings.

    Args:
        settings: Dictionary of configuration settings
    """
    ...

print_error(message)

Display error message.

Parameters:

Name Type Description Default
message str

Error message to display

required
Source code in src/appimage_updater/ui/output/interface.py
def print_error(self, message: str) -> None:
    """Display error message.

    Args:
        message: Error message to display
    """
    ...

print_info(message)

Display info message.

Parameters:

Name Type Description Default
message str

Info message to display

required
Source code in src/appimage_updater/ui/output/interface.py
def print_info(self, message: str) -> None:
    """Display info message.

    Args:
        message: Info message to display
    """
    ...

print_progress(current, total, description='')

Display progress information.

Parameters:

Name Type Description Default
current int

Current progress value

required
total int

Total progress value

required
description str

Optional progress description

''
Source code in src/appimage_updater/ui/output/interface.py
def print_progress(self, current: int, total: int, description: str = "") -> None:
    """Display progress information.

    Args:
        current: Current progress value
        total: Total progress value
        description: Optional progress description
    """
    ...

print_success(message)

Display success message.

Parameters:

Name Type Description Default
message str

Success message to display

required
Source code in src/appimage_updater/ui/output/interface.py
def print_success(self, message: str) -> None:
    """Display success message.

    Args:
        message: Success message to display
    """
    ...

print_table(data, title='', headers=None)

Display tabular data.

Parameters:

Name Type Description Default
data list[dict[str, Any]]

List of dictionaries representing table rows

required
title str

Optional table title

''
headers list[str] | None

Optional custom headers (uses dict keys if not provided)

None
Source code in src/appimage_updater/ui/output/interface.py
def print_table(self, data: list[dict[str, Any]], title: str = "", headers: list[str] | None = None) -> None:
    """Display tabular data.

    Args:
        data: List of dictionaries representing table rows
        title: Optional table title
        headers: Optional custom headers (uses dict keys if not provided)
    """
    ...

print_warning(message)

Display warning message.

Parameters:

Name Type Description Default
message str

Warning message to display

required
Source code in src/appimage_updater/ui/output/interface.py
def print_warning(self, message: str) -> None:
    """Display warning message.

    Args:
        message: Warning message to display
    """
    ...

start_section(title)

Start a new output section.

Parameters:

Name Type Description Default
title str

Section title

required
Source code in src/appimage_updater/ui/output/interface.py
def start_section(self, title: str) -> None:
    """Start a new output section.

    Args:
        title: Section title
    """
    ...

OutputFormatterContext(formatter)

Context manager for output formatter.

Parameters:

Name Type Description Default
formatter Any

Output formatter to use in this context

required
Source code in src/appimage_updater/ui/output/context.py
def __init__(self, formatter: Any):
    """Initialize context manager.

    Args:
        formatter: Output formatter to use in this context
    """
    self.formatter = formatter
    self.token: Token[Any] | None = None

formatter = formatter instance-attribute

token = None instance-attribute

create_output_formatter(format_type, **kwargs)

Create appropriate output formatter based on format type.

Parameters:

Name Type Description Default
format_type OutputFormat

The desired output format

required
**kwargs Any

Additional arguments passed to formatter constructor

{}

Returns:

Type Description
OutputFormatter

OutputFormatter instance for the specified format

Raises:

Type Description
ValueError

If format_type is not supported

Source code in src/appimage_updater/ui/output/factory.py
def create_output_formatter(format_type: OutputFormat, **kwargs: Any) -> OutputFormatter:
    """Create appropriate output formatter based on format type.

    Args:
        format_type: The desired output format
        **kwargs: Additional arguments passed to formatter constructor

    Returns:
        OutputFormatter instance for the specified format

    Raises:
        ValueError: If format_type is not supported
    """
    if format_type == OutputFormat.RICH:
        return RichOutputFormatter(**kwargs)
    elif format_type == OutputFormat.PLAIN:
        return PlainOutputFormatter(**kwargs)
    elif format_type == OutputFormat.JSON:
        return JSONOutputFormatter(**kwargs)
    elif format_type == OutputFormat.HTML:
        return HTMLOutputFormatter(**kwargs)
    else:
        raise ValueError(f"Unsupported output format: {format_type}")

create_output_formatter_from_params(params)

Create formatter based on command parameters.

Parameters:

Name Type Description Default
params Any

Command parameters object containing format attribute

required

Returns:

Type Description
OutputFormatter

OutputFormatter instance based on params.format

Source code in src/appimage_updater/ui/output/factory.py
def create_output_formatter_from_params(params: Any) -> OutputFormatter:
    """Create formatter based on command parameters.

    Args:
        params: Command parameters object containing format attribute

    Returns:
        OutputFormatter instance based on params.format
    """
    format_type = getattr(params, "format", OutputFormat.RICH)
    verbose = getattr(params, "verbose", False)

    # Pass verbose flag to formatter if supported
    kwargs = {}
    if hasattr(params, "verbose"):
        kwargs["verbose"] = verbose

    return create_output_formatter(format_type, **kwargs)

get_output_formatter()

Get the current output formatter from context.

Returns:

Type Description
Any

Current output formatter or None if not set

Source code in src/appimage_updater/ui/output/context.py
def get_output_formatter() -> Any:
    """Get the current output formatter from context.

    Returns:
        Current output formatter or None if not set
    """
    return _output_formatter.get()

set_output_formatter(formatter)

Set the output formatter in context.

Parameters:

Name Type Description Default
formatter Any

Output formatter to set

required
Source code in src/appimage_updater/ui/output/context.py
def set_output_formatter(formatter: Any) -> None:
    """Set the output formatter in context.

    Args:
        formatter: Output formatter to set
    """
    _output_formatter.set(formatter)