From f3c2b77b1f9296734205c288cfb35a46bdf6fab0 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Wed, 13 Mar 2024 03:22:39 +0100 Subject: [PATCH] move the screenshots code part to only run it once, since it do not change with language --- tools/readme_generator/make_readme.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/readme_generator/make_readme.py b/tools/readme_generator/make_readme.py index 574191c55e..07e5001145 100755 --- a/tools/readme_generator/make_readme.py +++ b/tools/readme_generator/make_readme.py @@ -51,6 +51,16 @@ def generate_READMEs(app_path: Path): env = Environment(loader=FileSystemLoader(Path(__file__).parent / "templates")) + screenshots: List[str] + screenshots = [] + if (app_path / "doc" / "screenshots").exists(): + # only pick files (no folder) on the root of 'screenshots' + for entry in os.scandir(os.path.join(app_path, "doc", "screenshots")): + if os.DirEntry.is_file(entry): + # ignore '.gitkeep' or any file whose name begins with a dot + if not entry.name.startswith("."): + screenshots.append(os.path.relpath(entry.path, app_path)) + # parse available README template and generate a list in the form of: # > [("en", ""), ("fr", "_fr"), ...] available_langs: List[Tuple[str, str]] = [("en", "")] @@ -81,16 +91,6 @@ def generate_READMEs(app_path: Path): else: description = None - screenshots: List[str] - screenshots = [] - if (app_path / "doc" / "screenshots").exists(): - # only pick files (no folder) on the root of 'screenshots' - for entry in os.scandir(os.path.join(app_path, "doc", "screenshots")): - if os.DirEntry.is_file(entry): - # ignore '.gitkeep' or any file whose name begins with a dot - if not entry.name.startswith("."): - screenshots.append(os.path.relpath(entry.path, app_path)) - disclaimer: Optional[str] if (app_path / "doc" / f"DISCLAIMER{lang_suffix}.md").exists(): disclaimer = (app_path / "doc" / f"DISCLAIMER{lang_suffix}.md").read_text()