Fix antifeatures list generation
This commit is contained in:
parent
1d19f28c9a
commit
3b8576149a
3 changed files with 21 additions and 8 deletions
|
@ -8,6 +8,15 @@ from pathlib import Path
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
|
def value_for_lang(values, lang):
|
||||||
|
if not isinstance(values, dict):
|
||||||
|
return values
|
||||||
|
if lang in values:
|
||||||
|
return values[lang]
|
||||||
|
elif "en" in values:
|
||||||
|
return values["en"]
|
||||||
|
else:
|
||||||
|
return list(values.values())[0]
|
||||||
|
|
||||||
def generate_READMEs(app_path: str):
|
def generate_READMEs(app_path: str):
|
||||||
|
|
||||||
|
@ -22,7 +31,7 @@ def generate_READMEs(app_path: str):
|
||||||
catalog = json.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "apps.json"))
|
catalog = json.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "apps.json"))
|
||||||
from_catalog = catalog.get(manifest['id'], {})
|
from_catalog = catalog.get(manifest['id'], {})
|
||||||
|
|
||||||
antifeatures_list = yaml.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "antifeatures.yml"))
|
antifeatures_list = yaml.load(open(Path(os.path.abspath(__file__)).parent.parent.parent / "antifeatures.yml"), Loader=yaml.SafeLoader)
|
||||||
antifeatures_list = { e['id']: e for e in antifeatures_list }
|
antifeatures_list = { e['id']: e for e in antifeatures_list }
|
||||||
|
|
||||||
if not upstream and not (app_path / "doc" / "DISCLAIMER.md").exists():
|
if not upstream and not (app_path / "doc" / "DISCLAIMER.md").exists():
|
||||||
|
@ -62,12 +71,12 @@ def generate_READMEs(app_path: str):
|
||||||
|
|
||||||
# TODO: Add url to the documentation... and actually create that documentation :D
|
# TODO: Add url to the documentation... and actually create that documentation :D
|
||||||
antifeatures = { a: antifeatures_list[a] for a in from_catalog.get('antifeatures', [])}
|
antifeatures = { a: antifeatures_list[a] for a in from_catalog.get('antifeatures', [])}
|
||||||
for k, v in antifeatures:
|
for k, v in antifeatures.items():
|
||||||
v['title'] = v['title'].get(lang_suffix, 'en')
|
antifeatures[k]['title'] = value_for_lang(v['title'], lang_suffix)
|
||||||
if manifest.get("antifeatures", {}).get(k, 'en'):
|
if manifest.get("antifeatures", {}).get(k, None):
|
||||||
v['description'] = manifest.get("antifeatures", {}).get(k, 'en')
|
antifeatures[k]['description'] = value_for_lang(manifest.get("antifeatures", {}).get(k, None), lang_suffix)
|
||||||
else:
|
else:
|
||||||
antifeature['description'] = antifeature['description'].get(lang_suffix, 'en')
|
antifeatures[k]['description'] = value_for_lang(antifeatures[k]['description'], lang_suffix)
|
||||||
|
|
||||||
out = template.render(
|
out = template.render(
|
||||||
lang=lang,
|
lang=lang,
|
||||||
|
@ -75,6 +84,7 @@ def generate_READMEs(app_path: str):
|
||||||
description=description,
|
description=description,
|
||||||
screenshots=screenshots,
|
screenshots=screenshots,
|
||||||
disclaimer=disclaimer,
|
disclaimer=disclaimer,
|
||||||
|
antifeatures=antifeatures,
|
||||||
manifest=manifest,
|
manifest=manifest,
|
||||||
)
|
)
|
||||||
(app_path / f"README{lang_suffix}.md").write_text(out)
|
(app_path / f"README{lang_suffix}.md").write_text(out)
|
||||||
|
|
|
@ -52,8 +52,9 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
|
||||||
{% if antifeatures -%}
|
{% if antifeatures -%}
|
||||||
## Antifeatures
|
## Antifeatures
|
||||||
|
|
||||||
{% for antifeature in antifeatures -%}
|
{% for antifeature in antifeatures.values() -%}
|
||||||
- **{{ antifeature.title }}**: {{ antifeature.description }}
|
- **{{ antifeature.title }}**: {{ antifeature.description }}
|
||||||
|
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,13 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
|
||||||
{% if antifeatures -%}
|
{% if antifeatures -%}
|
||||||
## Fonctions indésirables
|
## Fonctions indésirables
|
||||||
|
|
||||||
{% for antifeature in antifeatures -%}
|
{% for antifeature in antifeatures.values() -%}
|
||||||
- **{{ antifeature.title }}**: {{ antifeature.description }}
|
- **{{ antifeature.title }}**: {{ antifeature.description }}
|
||||||
|
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
|
|
||||||
## Documentations et ressources
|
## Documentations et ressources
|
||||||
|
|
||||||
{% if upstream.website -%}* Site officiel de l'app : {{ upstream.website }}
|
{% if upstream.website -%}* Site officiel de l'app : {{ upstream.website }}
|
||||||
|
|
Loading…
Reference in a new issue