mirror of
https://github.com/walkxcode/dashboard-icons.git
synced 2024-11-08 21:04:15 +01:00
c7a85b2278
Co-authored-by: Bjorn Lammers <walkxnl@gmail.com> Co-authored-by: Prakash Palanisamy <prakash_gitea@itsprakash.in> Co-authored-by: Prakash Palanisamy <51423001+itsprakashp@users.noreply.github.com> Co-authored-by: Dashboard Icons Bot <noreply@walkx.fyi>
32 lines
919 B
Python
32 lines
919 B
Python
import pathlib
|
|
from pathlib import Path
|
|
|
|
root = pathlib.Path(__file__).parent.resolve()
|
|
icons_template_path = root / "_ICONS_TEMPLATE.md"
|
|
icons_path = root / "ICONS.md"
|
|
|
|
|
|
def generate_img_tag(file):
|
|
return f'<img src="png/{file.name}" alt="{file.stem}" height="50">'
|
|
|
|
|
|
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(icons_template_path, "r", encoding="UTF-8") as f:
|
|
lines = f.readlines()
|
|
# Find the line that starts with "<!-- ICONS -->"
|
|
for line in lines:
|
|
if line.startswith("<!-- ICONS -->"):
|
|
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(icons_path, "w", encoding="UTF-8") as f:
|
|
f.write("".join(lines))
|
|
f.write("\n")
|
|
print("Done!")
|
|
print("Please commit the new ICONS.md file.")
|