def WriteIndex(self):
    """ Write the master index of all Sitemap files """
    # Make a filename
    filename = self._filegen.GeneratePath(SITEINDEX_SUFFIX)
    if not filename:
      output.Fatal('Unexpected: Couldn\'t generate output index filename.')
    output.Log('Writing index file "%s" with %d Sitemaps' %
        (filename, self._sitemaps), 1)

   # Determine what Sitemap index header to use (News or General)
    if self._sitemap_type == 'news':
      sitemap_index_header = NEWS_SITEMAP_HEADER
    else:
      sitemap__index_header = GENERAL_SITEMAP_HEADER
 
    # Make a lastmod time
    lastmod = TimestampISO8601(time.time())

    # Write to it
    try:
      fd = open(filename, 'wt')
      fd.write(sitemap_index_header)

      for mapnumber in range(0,self._sitemaps):
        # Write the entry
        mapurl = self._filegen.GenerateURL(mapnumber, self._base_url)
        mapattributes = { 'loc' : mapurl, 'lastmod' : lastmod }
        fd.write(SITEINDEX_ENTRY % mapattributes)

      fd.write(SITEINDEX_FOOTER)

      fd.close()
      fd = None
    except __HOLE__:
      output.Fatal('Couldn\'t write out to file: %s' % filename)
    os.chmod(filename, 0644)
  #end def WriteIndex
dataset/ETHPy150Open benoitc/restkit/doc/sitemap_gen.py/Sitemap.WriteIndex