1
0
Fork 0

make_readme: use get_apps_repo

This commit is contained in:
Félix Piédallu 2024-08-11 22:55:33 +02:00 committed by Salamandar
parent 71420f1c17
commit a039a43ed6
2 changed files with 20 additions and 7 deletions

View file

@ -1,5 +1,6 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
import sys
import os import os
import argparse import argparse
import json import json
@ -14,8 +15,12 @@ from babel.support import Translations
from babel.messages.pofile import PoFileParser from babel.messages.pofile import PoFileParser
from langcodes import Language from langcodes import Language
# add apps/tools to sys.path
sys.path.insert(0, str(Path(__file__).parent.parent))
from appslib import get_apps_repo
README_GEN_DIR = Path(__file__).resolve().parent README_GEN_DIR = Path(__file__).resolve().parent
APPS_REPO_ROOT = README_GEN_DIR.parent.parent
TRANSLATIONS_DIR = README_GEN_DIR / "translations" TRANSLATIONS_DIR = README_GEN_DIR / "translations"
@ -31,7 +36,7 @@ def value_for_lang(values: Dict, lang: str):
return list(values.values())[0] return list(values.values())[0]
def generate_READMEs(app_path: Path): def generate_READMEs(app_path: Path, catalog_path: Path):
if not app_path.exists(): if not app_path.exists():
raise Exception("App path provided doesn't exists ?!") raise Exception("App path provided doesn't exists ?!")
@ -42,11 +47,11 @@ def generate_READMEs(app_path: Path):
upstream = manifest.get("upstream", {}) upstream = manifest.get("upstream", {})
catalog = toml.load((APPS_REPO_ROOT / "apps.toml").open(encoding="utf-8")) catalog = toml.load((catalog_path / "apps.toml").open(encoding="utf-8"))
from_catalog = catalog.get(manifest["id"], {}) from_catalog = catalog.get(manifest["id"], {})
antifeatures_list = toml.load( antifeatures_list = toml.load(
(APPS_REPO_ROOT / "antifeatures.toml").open(encoding="utf-8") (catalog_path / "antifeatures.toml").open(encoding="utf-8")
) )
if not upstream and not (app_path / "doc" / "DISCLAIMER.md").exists(): if not upstream and not (app_path / "doc" / "DISCLAIMER.md").exists():
@ -195,6 +200,9 @@ if __name__ == "__main__":
parser.add_argument( parser.add_argument(
"app_path", type=Path, help="Path to the app to generate/update READMEs for" "app_path", type=Path, help="Path to the app to generate/update READMEs for"
) )
get_apps_repo.add_args(parser)
args = parser.parse_args() args = parser.parse_args()
generate_READMEs(Path(args.app_path))
apps_path = get_apps_repo.from_args(args)
generate_READMEs(Path(args.app_path), apps_path)

View file

@ -27,7 +27,12 @@ def test_running_make_readme():
# Now run test... # Now run test...
subprocess.check_call( subprocess.check_call(
[TEST_DIRECTORY.parent / "make_readme.py", temporary_tested_app_directory] [
TEST_DIRECTORY.parent / "make_readme.py",
"-l",
TEST_DIRECTORY.parent.parent.parent,
temporary_tested_app_directory,
]
) )
assert ( assert (