aboutsummaryrefslogtreecommitdiff
path: root/repos/__init__.py
blob: 70230716e27ff4ba8a420c0cacf5964ee412df9c (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, arch_linux, crates_io
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),
    *repos_from(crates_io),
]

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