mirror of
https://github.com/ksherlock/ample.git
synced 2024-10-30 07:24:28 +00:00
38 lines
625 B
Python
38 lines
625 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("Resources/devices.plist", "w") as f:
|
||
|
f.write(to_plist(devices))
|