Skip to content

topmark.presentation.shared.outcomes

topmark / presentation / shared / outcomes

CLI-oriented outcome helpers.

This module layers CLI semantic styling concerns on top of the pure bucketing logic in topmark.pipeline.outcomes.

It is Click-free by design, so it can be reused from tests and other frontends.

get_outcome_style_role

get_outcome_style_role(outcome)

Return the semantic style role used for a given outcome.

Parameters:

Name Type Description Default
outcome Outcome

The public outcome.

required

Returns:

Type Description
StyleRole

The semantic StyleRole corresponding to outcome.

Source code in src/topmark/presentation/shared/outcomes.py
def get_outcome_style_role(outcome: Outcome) -> StyleRole:
    """Return the semantic style role used for a given outcome.

    Args:
        outcome: The public outcome.

    Returns:
        The semantic `StyleRole` corresponding to `outcome`.
    """
    role: StyleRole = _OUTCOME_STYLE_ROLE.get(outcome, StyleRole.NO_STYLE)
    return role

get_outcome_styler

get_outcome_styler(outcome)

Return the semantic text styler used for a given outcome.

Parameters:

Name Type Description Default
outcome Outcome

The public outcome.

required

Returns:

Type Description
TextStyler

The CLI text styler resolved from the mapped semantic StyleRole.

Source code in src/topmark/presentation/shared/outcomes.py
def get_outcome_styler(outcome: Outcome) -> TextStyler:
    """Return the semantic text styler used for a given outcome.

    Args:
        outcome: The public outcome.

    Returns:
        The CLI text styler resolved from the mapped semantic `StyleRole`.
    """
    role: StyleRole = get_outcome_style_role(outcome)
    return style_for_role(role)

collect_outcome_counts_styled

collect_outcome_counts_styled(results)

Return styled summary rows grouped by (outcome, reason).

Parameters:

Name Type Description Default
results list[ProcessingContext]

Processing contexts to classify and count.

required

Returns:

Type Description
list[tuple[OutcomeReasonCount, TextStyler]]

Stable summary rows paired with the CLI text styler for their semantic outcome role.

Source code in src/topmark/presentation/shared/outcomes.py
def collect_outcome_counts_styled(
    results: list[ProcessingContext],
) -> list[tuple[OutcomeReasonCount, TextStyler]]:
    """Return styled summary rows grouped by `(outcome, reason)`.

    Args:
        results: Processing contexts to classify and count.

    Returns:
        Stable summary rows paired with the CLI text styler for their semantic outcome role.
    """
    counts: list[OutcomeReasonCount] = collect_outcome_reason_counts(results)
    return [(row, get_outcome_styler(row.outcome)) for row in counts]