From 1a58b136e3fcd582fc9fc43ced0305405ab65758 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Thu, 11 Aug 2022 06:18:56 +0200 Subject: [PATCH] distro: add Distro.{scan,is_scanned}() --- distro/distro.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/distro/distro.py b/distro/distro.py index 33d4910..da437d1 100644 --- a/distro/distro.py +++ b/distro/distro.py @@ -1,6 +1,6 @@ from typing import Optional, Mapping -from constants import ARCHES, BASE_DISTROS, REPOSITORIES, KUPFER_HTTPS, CHROOT_PATHS +from constants import Arch, ARCHES, BASE_DISTROS, REPOSITORIES, KUPFER_HTTPS, CHROOT_PATHS from generator import generate_pacman_conf_body from config import config @@ -12,7 +12,7 @@ class Distro: repos: Mapping[str, Repo] arch: str - def __init__(self, arch: str, repo_infos: dict[str, RepoInfo], scan=False): + def __init__(self, arch: Arch, repo_infos: dict[str, RepoInfo], scan=False): assert (arch in ARCHES) self.arch = arch self.repos = dict[str, Repo]() @@ -41,6 +41,17 @@ class Distro: body = generate_pacman_conf_body(self.arch, check_space=check_space) return body + self.repos_config_snippet(extra_repos) + def scan(self, lazy=True): + for repo in self.repos.values(): + if not (lazy and repo.scanned): + repo.scan() + + def is_scanned(self): + for repo in self.repos.values(): + if not repo.scanned: + return False + return True + def get_base_distro(arch: str) -> Distro: repos = {name: RepoInfo(url_template=url) for name, url in BASE_DISTROS[arch]['repos'].items()}