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

from . import alpine_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),
]

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