5 from xml.dom import minidom
27 def getChild(accessible, i):
29 child = accessible.getChildAtIndex(i)
34 def createNode(accessible, parentRef, parentElement):
35 e = minidom.Element("accessible")
36 reference = '/' + str(uuid.uuid4()).replace('-', '')
38 e.attributes["reference"] = reference
39 e.attributes["parent"] = parentRef
40 e.attributes["name"] = accessible.name
41 e.attributes["role"] = str(accessible.getRole())
42 e.attributes["description"] = accessible.description
45 query = getattr(accessible, "query" + i)
48 itf = minidom.Element("interface")
49 itf.attributes["name"] = i
51 except NotImplementedError:
57 count = accessible.childCount
61 for i in range(count):
62 child = getChild(accessible, i)
64 createNode(child, reference, e)
66 parentElement.appendChild(e)
70 doc = minidom.Document()
71 desk = pyatspi.Registry.getDesktop(0)
72 createNode(desk, '/', doc)
74 file = open(filename, 'w')
75 file.write(doc.toprettyxml())
78 if __name__ == "__main__":
79 sys.exit(main(sys.argv))