def get_platform()

in bot/code_coverage_bot/taskcluster.py [0:0]


def get_platform(task):
    """
    Build clean platform from a Taskcluster task
    """
    assert isinstance(task, dict)
    tags = task.get("tags", {})
    platform = tags.get("os")

    # Fallback on parsing the task name for signing tasks, as they don't have "os" in their tags.
    name = task.get("metadata", {}).get("name", "")
    if not platform and "signing" in name:
        name = name.split("/")[0]
        if "linux" in name:
            platform = "linux"
        if "win" in name:
            assert platform is None
            platform = "windows"
        if "mac" in name:
            assert platform is None
            platform = "macosx"

    if not platform:
        raise Exception(f"Unknown platform for {task}")

    # Weird case for android build on Linux docker
    if platform == "linux" and tags.get("android-stuff"):
        return "android"

    return platform