from typing import Mapping, List from . import alpine_linux, arch_linux from .base import Repository, Version __all__ = [ 'get_versions', ] def repos_from(module): for exported in module.__all__: attr = getattr(module, exported) if isinstance(attr, Repository): yield attr all_repos: List[Repository] = [ *repos_from(alpine_linux), *repos_from(arch_linux), ] def get_versions(package: str) -> Mapping[str, Version]: result = dict() for repo in all_repos: repo_versions = repo.get_versions() if package in repo_versions: result[repo.full_name()] = repo_versions[package] return result