aboutsummaryrefslogtreecommitdiff
path: root/repos
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-29 18:52:31 -0600
committerMelody Horn <melody@boringcactus.com>2021-03-29 18:52:31 -0600
commit563eda8e7772a49ebe242b65849359db0a077672 (patch)
tree88cb421fba5982620f1d7f657a2fb2f86588c046 /repos
parente7b83c7c57483277fa243dd7ff1068c8ff33438f (diff)
downloadwhere-packaged-563eda8e7772a49ebe242b65849359db0a077672.tar.gz
where-packaged-563eda8e7772a49ebe242b65849359db0a077672.zip
flatten repository metastructure
Diffstat (limited to 'repos')
-rw-r--r--repos/__init__.py8
-rw-r--r--repos/base.py4
2 files changed, 5 insertions, 7 deletions
diff --git a/repos/__init__.py b/repos/__init__.py
index fc81260..ab6aa76 100644
--- a/repos/__init__.py
+++ b/repos/__init__.py
@@ -1,7 +1,7 @@
from typing import Mapping, List
from . import alpine_linux, arch_linux
-from .base import Repository
+from .base import Repository, Version
__all__ = [
'get_versions',
@@ -18,12 +18,10 @@ all_repos: List[Repository] = [
*repos_from(arch_linux),
]
-def get_versions(package: str) -> Mapping[str, Mapping[str, str]]:
+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:
- if repo.family not in result:
- result[repo.family] = dict()
- result[repo.family][repo.repo] = repo_versions[package]
+ result[repo.full_name()] = repo_versions[package]
return result
diff --git a/repos/base.py b/repos/base.py
index 1bd4ae3..c7790c1 100644
--- a/repos/base.py
+++ b/repos/base.py
@@ -60,7 +60,7 @@ class Repository:
index_url: str
parse: Callable[[Path], Mapping[str, Version]]
- def _full_name(self):
+ def full_name(self):
return f'{self.family} {self.repo}'
def _cache_dir(self) -> Path:
@@ -88,7 +88,7 @@ class Repository:
response = requests.get(self.index_url, headers=headers, stream=True)
if response.status_code != requests.codes.not_modified:
response.raise_for_status()
- print('Re-downloading', self._full_name())
+ print('Re-downloading', self.full_name())
with downloaded_file.open('wb') as f:
for chunk in response.iter_content(chunk_size=256):
f.write(chunk)