def writeContentsFile(documentDirectoryPath, hypertextFiles):
 output = cStringIO.StringIO()
 output.write('<html>\n  <head>\n    <title>Contents</title>\n  </head>\n  <body>\n')
 navigationLine = getNavigationLine('Contents', 'Previous', getNextLinkText(hypertextFiles, 0))
 output.write(navigationLine)
 for hypertextFile in hypertextFiles:
  writeContentsLine(hypertextFile, output)
 output.write(navigationLine)
 output.write('  </body>\n</html>\n')
 filePath = os.path.join(documentDirectoryPath, 'contents.html')
 archive.writeFileText(filePath, output.getvalue())

def writeContentsFile ( documentDirectoryPath , hypertextFiles ) : output = cStringIO . StringIO ( ) output . write ( '<html>\n  <head>\n    <title>Contents</title>\n  </head>\n  <body>\n' ) navigationLine = getNavigationLine ( 'Contents' , 'Previous' , getNextLinkText ( hypertextFiles , 0 ) ) output . write ( navigationLine ) for hypertextFile in hypertextFiles : writeContentsLine ( hypertextFile , output ) output . write ( navigationLine ) output . write ( '  </body>\n</html>\n' ) filePath = os . path . join ( documentDirectoryPath , 'contents.html' ) archive . writeFileText ( filePath , output . getvalue ( ) )
write the contents file .