packages/pkgbuild: add get_pkgbuild_by_name(name, lazy=True) for easy cache access

This commit is contained in:
InsanePrawn 2022-09-08 01:48:08 +02:00
parent e4320578ef
commit 1fd84bb9c2

View file

@ -292,6 +292,16 @@ def get_pkgbuild_by_path(relative_path: str, lazy: bool = True, _config: Optiona
return parsed
def get_pkgbuild_by_name(name: str, lazy: bool = True):
if lazy and name in _pkgbuilds_cache:
return _pkgbuilds_cache[name]
if _pkgbuilds_scanned and lazy:
raise Exception(f"couldn't find PKGBUILD for package with name {name}")
discover_pkgbuilds(lazy=lazy)
assert _pkgbuilds_scanned
return get_pkgbuild_by_name(name=name, lazy=lazy)
def discover_pkgbuilds(parallel: bool = True, lazy: bool = True) -> dict[str, Pkgbuild]:
global _pkgbuilds_cache, _pkgbuilds_scanned
if lazy and _pkgbuilds_scanned: