def status_str()

in sync/notify/msg.py [0:0]


def status_str(result: Result | SubtestResult | TestResult,
               browser: str = "firefox",
               include_status: str = "head",
               include_other_browser: bool = False,
               ) -> str | None:
    """Construct a string containing the statuses for a results.

    :param result: The Result object for which to construct the string.
    :param browser: The primary browser for which to construct the result
    :param include_status: Either "head" to just include the updated status or
                           "both" to include both the head and base statuses.
    :param include_other_browser: Boolean indicating whether to include results from
                                  non-primary browsers.
    """
    targets = {"head": ["head"],
               "both": ["base", "head"]}[include_status]

    if all(result.is_consistent(browser, target) for target in targets):
        value = "->".join(f"`{getattr(next(iter(result.statuses[browser].values())), target)}`"
                          for target in targets)
    else:
        by_value = defaultdict(list)
        results = result.statuses[browser]
        for job_name, status in results.items():
            key = tuple(getattr(status, target) for target in targets)
            by_value[key].append(job_name)

        value = ", ".join("{} [{}]".format("->".join(f"`{status}`" for status in statuses),
                                           ", ".join("`%s`" % item for item in sorted(job_names)))
                          for statuses, job_names in sorted(by_value.items()))

    if include_other_browser:
        other_browser_values = []
        for other_browser, job_results in sorted(result.statuses.items()):
            if other_browser == browser:
                continue
            browser_status = job_results.get("GitHub")
            if not browser_status:
                return None
            other_browser_values.append("{}: {}".format(other_browser.title(),
                                                        "->".join(
                                                        f"`{getattr(browser_status, target)}`"
                                                        for target in targets)))
        if other_browser_values:
            value += " (%s)" % ", ".join(other_browser_values)
    return value