code: def parse_data(data, type, **kwargs):
      
      suffixes = {
          'xml': '.osm',
          'pbf': '.pbf',
      }
      try:
          suffix = suffixes[type]
      except KeyError:
          raise ValueError('Unknown data type "%s"' % type)
  
      fd, filename = tempfile.mkstemp(suffix=suffix)
      try:
          os.write(fd, data)
          os.close(fd)
          return parse_file(filename, **kwargs)
      finally:
          os.remove(filename)
docs: Return an OSM networkx graph from the input OSM data
  
      Parameters
      ----------
      data : string
      type : string ('xml' or 'pbf')
  
      >>> graph = parse_data(data, 'xml')