28 lines
832 B
Python
28 lines
832 B
Python
|
#!/usr/bin/python
|
||
|
# Copyright 2022 (c) Anna Schumaker.
|
||
|
"""Generate the emmental.gresource.xml file."""
|
||
|
from xml.dom import minidom
|
||
|
import pathlib
|
||
|
|
||
|
project_dir = pathlib.Path(__file__).parent.parent
|
||
|
resource_file = project_dir / "emmental.gresource.xml"
|
||
|
|
||
|
xml = minidom.Document()
|
||
|
|
||
|
gresources = xml.createElement("gresources")
|
||
|
xml.appendChild(gresources)
|
||
|
|
||
|
gresource = xml.createElement("gresource")
|
||
|
gresource.setAttribute("prefix", "/com/nowheycreamery/emmental")
|
||
|
gresources.appendChild(gresource)
|
||
|
|
||
|
for f in (project_dir / "icons").glob("**/*"):
|
||
|
if f.is_file():
|
||
|
file = xml.createElement("file")
|
||
|
text = xml.createTextNode(str(f.relative_to(project_dir)))
|
||
|
file.appendChild(text)
|
||
|
gresource.appendChild(file)
|
||
|
|
||
|
with open(project_dir / "emmental.gresource.xml", "w") as f:
|
||
|
f.write(xml.toprettyxml())
|