4 from dbus.mainloop.glib import DBusGMainLoop
6 from xml.dom import minidom
8 from AccessibleTreeCache import AccessibleTreeCache, AccessibleObjectProxy
10 DBusGMainLoop(set_as_default=True)
12 def createNode(accessible, parentRef, parentElement):
13 e = minidom.Element("accessible")
15 e.attributes["reference"] = accessible.path
16 e.attributes["parent"] = accessible.parent
17 e.attributes["name"] = accessible.name
18 e.attributes["role"] = str(int(accessible.role))
19 e.attributes["description"] = accessible.description
21 for i in accessible.interfaces:
22 itf = minidom.Element("interface")
23 itf.attributes["name"] = i
26 for c in accessible.getChildren():
27 createNode(c, accessible.path, e)
29 parentElement.appendChild(e)
33 bus = dbus.SessionBus()
35 loop = gobject.MainLoop()
37 cache = AccessibleTreeCache(bus, 'test.atspi.tree', '/org/freedesktop/atspi/tree')
38 root = cache.getRootAccessible()
40 doc = minidom.Document()
41 createNode(root, '/', doc)
43 file = open(filename, 'w')
44 file.write(doc.toprettyxml())
47 if __name__ == '__main__':
48 sys.exit(main(sys.argv))