home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / python2.4 / site-packages / dbus / introspect_parser.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-08-31  |  1.5 KB  |  53 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import libxml2
  5. import cStringIO
  6. import exceptions
  7.  
  8. def process_introspection_data(data):
  9.     method_map = { }
  10.     XMLREADER_START_ELEMENT_NODE_TYPE = 1
  11.     XMLREADER_END_ELEMENT_NODE_TYPE = 15
  12.     stream = cStringIO.StringIO(data.encode('utf-8'))
  13.     input_source = libxml2.inputBuffer(stream)
  14.     reader = input_source.newTextReader('urn:introspect')
  15.     ret = reader.Read()
  16.     current_iface = None
  17.     current_method = None
  18.     current_sigstr = ''
  19.     while ret == 1:
  20.         name = reader.LocalName()
  21.         if reader.NodeType() == XMLREADER_START_ELEMENT_NODE_TYPE:
  22.             if not current_iface and not current_method and name == 'interface':
  23.                 current_iface = reader.GetAttribute('name')
  24.             elif current_iface and not current_method and name == 'method':
  25.                 current_method = reader.GetAttribute('name')
  26.                 if reader.IsEmptyElement():
  27.                     method_map[current_iface + '.' + current_method] = ''
  28.                     current_method = None
  29.                     current_sigstr = ''
  30.                 
  31.             elif current_iface and current_method and name == 'arg':
  32.                 direction = reader.GetAttribute('direction')
  33.                 if not direction or direction == 'in':
  34.                     current_sigstr = current_sigstr + reader.GetAttribute('type')
  35.                 
  36.             
  37.         elif reader.NodeType() == XMLREADER_END_ELEMENT_NODE_TYPE:
  38.             if current_iface and not current_method and name == 'interface':
  39.                 current_iface = None
  40.             
  41.             if current_iface and current_method and name == 'method':
  42.                 method_map[current_iface + '.' + current_method] = current_sigstr
  43.                 current_method = None
  44.                 current_sigstr = ''
  45.             
  46.         
  47.         ret = reader.Read()
  48.     if ret != 0:
  49.         raise exceptions.IntrospectionParserException(data)
  50.     
  51.     return method_map
  52.  
  53.