mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
add antifeatures to app catalog
This commit is contained in:
parent
70a8225b1d
commit
eeec30d78c
2 changed files with 38 additions and 23 deletions
|
@ -756,6 +756,10 @@ app:
|
||||||
full: --with-categories
|
full: --with-categories
|
||||||
help: Also return a list of app categories
|
help: Also return a list of app categories
|
||||||
action: store_true
|
action: store_true
|
||||||
|
-a:
|
||||||
|
full: --with-antifeatures
|
||||||
|
help: Also return a list of antifeatures categories
|
||||||
|
action: store_true
|
||||||
|
|
||||||
### app_search()
|
### app_search()
|
||||||
search:
|
search:
|
||||||
|
|
|
@ -41,12 +41,12 @@ APPS_CATALOG_API_VERSION = 3
|
||||||
APPS_CATALOG_DEFAULT_URL = "https://app.yunohost.org/default"
|
APPS_CATALOG_DEFAULT_URL = "https://app.yunohost.org/default"
|
||||||
|
|
||||||
|
|
||||||
def app_catalog(full=False, with_categories=False):
|
def app_catalog(full=False, with_categories=False, with_antifeatures=False):
|
||||||
"""
|
"""
|
||||||
Return a dict of apps available to installation from Yunohost's app catalog
|
Return a dict of apps available to installation from Yunohost's app catalog
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from yunohost.app import _installed_apps, _set_default_ask_questions
|
from yunohost.app import _installed_apps
|
||||||
|
|
||||||
# Get app list from catalog cache
|
# Get app list from catalog cache
|
||||||
catalog = _load_apps_catalog()
|
catalog = _load_apps_catalog()
|
||||||
|
@ -65,28 +65,38 @@ def app_catalog(full=False, with_categories=False):
|
||||||
"description": infos["manifest"]["description"],
|
"description": infos["manifest"]["description"],
|
||||||
"level": infos["level"],
|
"level": infos["level"],
|
||||||
}
|
}
|
||||||
else:
|
|
||||||
infos["manifest"]["install"] = _set_default_ask_questions(
|
|
||||||
infos["manifest"].get("install", {})
|
|
||||||
)
|
|
||||||
|
|
||||||
# Trim info for categories if not using --full
|
_catalog = {"apps": catalog["apps"]}
|
||||||
for category in catalog["categories"]:
|
|
||||||
category["title"] = _value_for_locale(category["title"])
|
|
||||||
category["description"] = _value_for_locale(category["description"])
|
|
||||||
for subtags in category.get("subtags", []):
|
|
||||||
subtags["title"] = _value_for_locale(subtags["title"])
|
|
||||||
|
|
||||||
if not full:
|
if with_categories:
|
||||||
catalog["categories"] = [
|
for category in catalog["categories"]:
|
||||||
{"id": c["id"], "description": c["description"]}
|
category["title"] = _value_for_locale(category["title"])
|
||||||
for c in catalog["categories"]
|
category["description"] = _value_for_locale(category["description"])
|
||||||
]
|
for subtags in category.get("subtags", []):
|
||||||
|
subtags["title"] = _value_for_locale(subtags["title"])
|
||||||
|
|
||||||
if not with_categories:
|
if not full:
|
||||||
return {"apps": catalog["apps"]}
|
catalog["categories"] = [
|
||||||
else:
|
{"id": c["id"], "description": c["description"]}
|
||||||
return {"apps": catalog["apps"], "categories": catalog["categories"]}
|
for c in catalog["categories"]
|
||||||
|
]
|
||||||
|
|
||||||
|
_catalog["categories"] = catalog["categories"]
|
||||||
|
|
||||||
|
if with_antifeatures:
|
||||||
|
for antifeature in catalog["antifeatures"]:
|
||||||
|
antifeature["title"] = _value_for_locale(antifeature["title"])
|
||||||
|
antifeature["description"] = _value_for_locale(antifeature["description"])
|
||||||
|
|
||||||
|
if not full:
|
||||||
|
catalog["antifeatures"] = [
|
||||||
|
{"id": a["id"], "description": a["description"]}
|
||||||
|
for a in catalog["antifeatures"]
|
||||||
|
]
|
||||||
|
|
||||||
|
_catalog["antifeatures"] = catalog["antifeatures"]
|
||||||
|
|
||||||
|
return _catalog
|
||||||
|
|
||||||
|
|
||||||
def app_search(string):
|
def app_search(string):
|
||||||
|
@ -211,7 +221,7 @@ def _load_apps_catalog():
|
||||||
corresponding to all known apps and categories
|
corresponding to all known apps and categories
|
||||||
"""
|
"""
|
||||||
|
|
||||||
merged_catalog = {"apps": {}, "categories": []}
|
merged_catalog = {"apps": {}, "categories": [], "antifeatures": []}
|
||||||
|
|
||||||
for apps_catalog_id in [L["id"] for L in _read_apps_catalog_list()]:
|
for apps_catalog_id in [L["id"] for L in _read_apps_catalog_list()]:
|
||||||
|
|
||||||
|
@ -261,7 +271,8 @@ def _load_apps_catalog():
|
||||||
info["repository"] = apps_catalog_id
|
info["repository"] = apps_catalog_id
|
||||||
merged_catalog["apps"][app] = info
|
merged_catalog["apps"][app] = info
|
||||||
|
|
||||||
# Annnnd categories
|
# Annnnd categories + antifeatures
|
||||||
merged_catalog["categories"] += apps_catalog_content["categories"]
|
merged_catalog["categories"] += apps_catalog_content["categories"]
|
||||||
|
merged_catalog["antifeatures"] += apps_catalog_content["antifeatures"]
|
||||||
|
|
||||||
return merged_catalog
|
return merged_catalog
|
||||||
|
|
Loading…
Add table
Reference in a new issue