1
0
Fork 0
mirror of https://github.com/YunoHost/apps.git synced 2024-09-03 20:06:07 +02:00

Simplify write_catalog_v3

This commit is contained in:
Salamandar 2024-06-06 12:23:14 +02:00
parent 237b154eee
commit f43f33c46e

View file

@ -82,20 +82,19 @@ def build_base_catalog(nproc: int):
def write_catalog_v3(base_catalog, target_dir: Path) -> None:
result_dict_with_manifest_v2 = copy.deepcopy(base_catalog)
# We also remove the app install question and resources parts which aint needed anymore
# by webadmin etc (or at least we think ;P)
for app in result_dict_with_manifest_v2.values():
if "manifest" in app and "install" in app["manifest"]:
del app["manifest"]["install"]
if "manifest" in app and "resources" in app["manifest"]:
del app["manifest"]["resources"]
logos_dir = target_dir / "logos"
logos_dir.mkdir(parents=True, exist_ok=True)
for appid, app in result_dict_with_manifest_v2.items():
appid = appid.lower()
logo_source = REPO_APPS_ROOT / "logos" / f"{appid}.png"
def infos_for_v3(app_id: str, infos: Any) -> Any:
# We remove the app install question and resources parts which aint
# needed anymore by webadmin etc (or at least we think ;P)
if "manifest" in infos and "install" in infos["manifest"]:
del infos["manifest"]["install"]
if "manifest" in infos and "resources" in infos["manifest"]:
del infos["manifest"]["resources"]
app_id = app_id.lower()
logo_source = REPO_APPS_ROOT / "logos" / f"{app_id}.png"
if logo_source.exists():
logo_hash = (
subprocess.check_output(["sha256sum", logo_source])
@ -107,10 +106,10 @@ def write_catalog_v3(base_catalog, target_dir: Path) -> None:
# FIXME: implement something to cleanup old logo stuf in the builds/.../logos/ folder somehow
else:
logo_hash = None
app["logo_hash"] = logo_hash
infos["logo_hash"] = logo_hash
full_catalog = {
"apps": result_dict_with_manifest_v2,
"apps": {app: infos_for_v3(app, info) for app, info in base_catalog.items()},
"categories": categories_list(),
"antifeatures": antifeatures_list(),
}