Changes to introspection generation to remove DOCTYPE and XML
[platform/core/uifw/at-spi2-atk.git] / tests / testClient.py
1 import sys
2 import gobject
3 import dbus
4 from dbus.mainloop.glib import DBusGMainLoop
5
6 from xml.dom import minidom
7
8 from AccessibleTreeCache import AccessibleTreeCache, AccessibleObjectProxy
9
10 DBusGMainLoop(set_as_default=True)
11
12 def createNode(accessible, parentRef, parentElement):
13         e = minidom.Element("accessible")
14
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
20
21         for i in accessible.interfaces:
22                 itf = minidom.Element("interface")
23                 itf.attributes["name"] = i
24                 e.appendChild(itf)
25
26         for c in accessible.getChildren():
27                 createNode(c, accessible.path, e)
28
29         parentElement.appendChild(e)
30
31 def main(argv):
32         filename = argv[1]
33         bus = dbus.SessionBus()
34         
35         loop = gobject.MainLoop()
36
37         cache = AccessibleTreeCache(bus, 'test.atspi.tree', '/org/freedesktop/atspi/tree')
38         root = cache.getRootAccessible()
39
40         doc = minidom.Document()
41         createNode(root, '/', doc)
42         
43         file = open(filename, 'w')
44         file.write(doc.toprettyxml())
45         file.close()
46
47 if __name__ == '__main__':
48         sys.exit(main(sys.argv))