Source code for fm_weck.version_listing

# This file is part of fm-weck: executing fm-tools in containerized environments.
# https://gitlab.com/sosy-lab/software/fm-weck
#
# SPDX-FileCopyrightText: 2024 Dirk Beyer <https://www.sosy-lab.org>
#
# SPDX-License-Identifier: Apache-2.0

from pathlib import Path

import yaml
from fm_tools.fmtoolversion import FmToolVersion
from tabulate import tabulate


[docs] class VersionListing: tool_and_version: dict[str, list] = {} def __init__(self, tool_paths: list[Path | FmToolVersion]): for tool_path in tool_paths: if isinstance(tool_path, Path): with open(tool_path) as stream: tool_data = yaml.safe_load(stream) else: tool_data = {"name": tool_path.get("name"), "versions": tool_path.get("versions")} versions = [version_data["version"] for version_data in tool_data["versions"]] self.tool_and_version[tool_data["name"]] = versions
[docs] def print_versions(self): data_list = list(self.tool_and_version.items()) print(tabulate(data_list, headers=["TOOL", "VERSIONS"], tablefmt="fancy_grid"))