mirror of
https://github.com/ksherlock/ample.git
synced 2024-10-31 15:04:56 +00:00
39 lines
635 B
Python
39 lines
635 B
Python
|
|
import subprocess
|
|
|
|
from plist import to_plist
|
|
|
|
import xml.etree.ElementTree as ET
|
|
|
|
from machines import MACHINES
|
|
|
|
|
|
devices = {}
|
|
|
|
for m in MACHINES:
|
|
|
|
|
|
st = subprocess.run(["mame", m, "-listxml"], capture_output=True)
|
|
if st.returncode != 0:
|
|
print("mame error: {}".format(m))
|
|
exit(1)
|
|
|
|
xml = st.stdout
|
|
root = ET.fromstring(xml)
|
|
|
|
nodes = root.findall("machine[@isdevice='yes']")
|
|
for d in nodes:
|
|
|
|
name = d.get("name") # devname
|
|
desc = d.find("description").text
|
|
|
|
tmp = {
|
|
"Name": name,
|
|
"Description": desc
|
|
}
|
|
devices[name] = tmp
|
|
|
|
|
|
with open("../Ample/Resources/devices.plist", "w") as f:
|
|
f.write(to_plist(devices))
|