summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <johnp@redhat.com>2005-10-06 04:43:52 +0000
committerJohn (J5) Palmieri <johnp@redhat.com>2005-10-06 04:43:52 +0000
commitf9e96c54cd2bad250179b2992870f8c27ae7e65d (patch)
tree7489d905ebb5a0e8e2f3763a451f6099ea12c4ff
parent86b9f6ad4a6f466e24b5e4c1c320029041c50e3b (diff)
* actualy add the introspection parser to CVS :-)
-rw-r--r--python/introspect_parser.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/python/introspect_parser.py b/python/introspect_parser.py
new file mode 100644
index 00000000..6e94cccf
--- /dev/null
+++ b/python/introspect_parser.py
@@ -0,0 +1,50 @@
+import libxml2
+import cStringIO
+import exceptions
+
+def process_introspection_data(data):
+ method_map = {}
+
+ XMLREADER_START_ELEMENT_NODE_TYPE = 1
+ XMLREADER_END_ELEMENT_NODE_TYPE = 15
+
+ stream = cStringIO.StringIO(data)
+ input_source = libxml2.inputBuffer(stream)
+ reader = input_source.newTextReader("urn:introspect")
+
+ ret = reader.Read()
+ current_iface=''
+ current_method=''
+ current_sigstr = ''
+
+ while ret == 1:
+ name = reader.LocalName()
+ if reader.NodeType() == XMLREADER_START_ELEMENT_NODE_TYPE:
+ if name == 'interface':
+ current_iface = reader.GetAttribute('name')
+ elif name == 'method':
+ current_method = reader.GetAttribute('name')
+ if reader.IsEmptyElement():
+ method_map[current_iface + '.' + current_method] = ''
+ current_method = ''
+ current_sigstr = ''
+
+ elif name == 'arg':
+ direction = reader.GetAttribute('direction')
+
+ if not direction or direction == 'in':
+ current_sigstr = current_sigstr + reader.GetAttribute('type')
+
+ elif reader.NodeType() == XMLREADER_END_ELEMENT_NODE_TYPE:
+ if name == 'method':
+ method_map[current_iface + '.' + current_method] = current_sigstr
+ current_method = ''
+ current_sigstr = ''
+
+
+ ret = reader.Read()
+
+ if ret != 0:
+ raise exceptions.IntrospectionParserException(data)
+
+ return method_map