anki/qt/aqt/forms/build_qrc.py
Henrik Giesel 3aebae9f13 Allow inclusion of external icons into aqt/forms/icons
+ Replace old tag icon with mdi tag and tag-off icon
2021-06-16 17:19:21 +10:00

26 lines
579 B
Python

import sys
import os
qrc_file = os.path.abspath(sys.argv[1])
icons = sys.argv[2:]
file_skeleton = """
<RCC>
<qresource prefix="/">
FILES
</qresource>
</RCC>
""".strip()
indent = " " * 8
lines = []
for icon in icons:
alias = ""
path = os.path.relpath(icon, start=os.path.dirname(qrc_file))
alias = "" if os.path.dirname(path) == "icons" else f' alias="icons/{os.path.basename(path)}"'
line = f"{indent}<file{alias}>{path}</file>"
lines.append(line)
with open(qrc_file, "w") as file:
file.write(file_skeleton.replace("FILES", "\n".join(lines)))