ansible-playbook-grapher/tests/generate-job-summary.py
Mohamed El Mouctar Haidara 76dbdacbe4
ci: Use ruff for linting and format (#199)
- Code cleanup with ruff
- Fix typos

---------

Co-authored-by: haidaraM <haidaraM@users.noreply.github.com>
2024-09-08 08:58:27 +02:00

26 lines
774 B
Python

import os
from pathlib import Path
from jinja2 import Template
DIR_PATH = Path(__file__).parent.resolve()
def list_mermaid_files() -> list[str]:
"""Return the list of files matching the pattern
:return:
"""
return list(map(str, Path(os.environ["MERMAID_FILES_PATH"]).rglob("*.mmd")))
if __name__ == "__main__":
with (DIR_PATH / "job-summary.md.j2").open() as template_file:
template = Template(template_file.read())
mermaid_files = list_mermaid_files()
matrix_job_identifier = os.environ["MATRIX_JOB_IDENTIFIER"]
files = []
for filename in mermaid_files:
files.append({"name": filename, "content": Path(filename).open().read()})
print(template.render(files=files, matrix_job_identifier=matrix_job_identifier))