aboutsummaryrefslogtreecommitdiff
path: root/repos/__init__.py
blob: fc812607a775a1c1975ed3e306d62f286cbc6baf (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
28
29
from typing import Mapping, List

from . import alpine_linux, arch_linux
from .base import Repository

__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, Mapping[str, str]]:
    result = dict()
    for repo in all_repos:
        repo_versions = repo.get_versions()
        if package in repo_versions:
            if repo.family not in result:
                result[repo.family] = dict()
            result[repo.family][repo.repo] = repo_versions[package]
    return result