#!/usr/bin/env python #---------- # # Placed into the public domain in November 2008 by Bob Harris. # # make_solution_html-- # Create html files to go along with the images created by # solution_to_pov_pieces.py # #---------- import sys #---------- # # make_solution_html-- # main program # #---------- def usage(s=None): message = """ make_solution_html title html_name_template image_name_template image_count """ if (s == None): sys.exit (message) else: sys.exit ("%s\n%s" % (s,message)) def main(): ########## # parse the command line ########## htmlTitle = None htmlTemplate = None imageTemplate = None numImages = None indexName = "index.html" solutionName = "solution.html" upName = None for arg in sys.argv[1:]: if ("=" in arg): val = arg.split("=",1)[1] else: val = None if (arg.startswith("--index=")): indexName = val elif (arg.startswith("--solution=")): solutionName = val elif (arg.startswith("--up=")): upName = val elif (htmlTitle == None): htmlTitle = arg elif (htmlTemplate == None): htmlTemplate = arg elif (imageTemplate == None): imageTemplate = arg elif (numImages == None): numImages = int(arg) assert (htmlTitle != None), "you need to give me an html title" assert (htmlTemplate != None), "you need to give me an html filename template" assert (imageTemplate != None), "you need to give me an image filename template" assert (numImages != None), "you need to tell me how many images there will be" ########## # write the html files ########## for num in range(1,numImages+1): if (num == 1): prev = numImages else: prev = num-1 if (num == numImages): next = 1 else: next = num+1 if (num == 1): fName = indexName elif (num == numImages): fName = solutionName else: fName = htmlTemplate % num if (prev == 1): prevName = indexName elif (prev == numImages): prevName = solutionName else: prevName = htmlTemplate % prev if (next == 1): nextName = indexName elif (next == numImages): nextName = solutionName else: nextName = htmlTemplate % next f = file(fName,"wt") print >>f,"" print >>f,"
" print >>f,"