From 72c5cfdbfbbcce3e598c78bb20413394767b43b8 Mon Sep 17 00:00:00 2001 From: Bjorn Lammers Date: Tue, 16 Aug 2022 18:51:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Adds=20Python=20for=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _ci.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 _ci.py diff --git a/_ci.py b/_ci.py new file mode 100644 index 00000000..cc27b919 --- /dev/null +++ b/_ci.py @@ -0,0 +1,32 @@ +import pathlib +from pathlib import Path + +root = pathlib.Path(__file__).parent.resolve() +template_path = root / "_TEMPLATE.md" +readme_path = root / "README.md" + + +def generate_img_tag(file): + return f'{file.stem}' + + +imgs = sorted(Path("./png").glob("*.png")) +img_tags = [generate_img_tag(x) for x in imgs] +line_number = 0 + +# Read the template file +with open(template_path, "r", encoding="UTF-8") as f: + lines = f.readlines() +# Find the line that starts with "" +for line in lines: + if line.startswith(""): + line_number = lines.index(line) + break +# Insert the icons after the line +lines.insert(line_number + 1, " ".join(img_tags)) +# Write the new file +with open(readme_path, "w", encoding="UTF-8") as f: + f.write("".join(lines)) + f.write("\n") +print("Done!") +print("Please commit the new README.md file.")