aboutsummaryrefslogtreecommitdiff
path: root/repos/__init__.py
blob: ab6aa760b6195db542cd42aee7828221a0045b22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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