import os, sys def publish(dirname, checkout_path, release): if not os.path.exists(dirname): os.mkdir(dirname) stylesheet_url = 'http://codespeak.net/icalendar/style.css' for name in ['example.txt', 'groupscheduled.txt', 'small.txt']: path = os.path.join(checkout_path, 'doc', name) outname = os.path.splitext(name)[0] + '.html' outpath = os.path.join(dirname, outname) print path, outpath rest2html(path, outpath, stylesheet_url) # also convert README.txt INSTALL.txt rest2html(os.path.join(checkout_path, 'README.txt'), os.path.join(dirname, 'index.html'), stylesheet_url) rest2html(os.path.join(checkout_path, 'INSTALL.txt'), os.path.join(dirname, 'installation.html'), stylesheet_url) rest2html(os.path.join(checkout_path, 'CHANGES.txt'), os.path.join(dirname, 'changes-%s.html' % release), stylesheet_url) # finally copy over interfaces.py literally f = open(os.path.join(checkout_path, 'src/icalendar/interfaces.py'), 'rb') data = f.read() f.close() f = open(os.path.join(dirname, 'interfaces.py'), 'wb') f.write(data) f.close() def rest2html(source_path, dest_path, stylesheet_url): command = ('rst2html.py --stylesheet=%s --link-stylesheet %s > %s' % (stylesheet_url, source_path, dest_path)) os.system(command) if __name__ == '__main__': publish(sys.argv[1], sys.argv[2], sys.argv[3])