emin

Thu, 04 Apr 2013 16:53:49 +0200

author
Andy Buckley <andy@insectnation.org>
date
Thu, 04 Apr 2013 16:53:49 +0200
changeset 23
4e1d30c61d0e
parent 21
71e18d3b1685
child 24
02f21810d43d
permissions
-rwxr-xr-x

Avoid 'underlined linebreak' in HTML rendering

andy@1 1 #! /usr/bin/env python
andy@1 2 # -*- python -*-
andy@1 3
andy@14 4 """%prog [opts] dir [outdir]
andy@3 5
andy@14 6 emin - a static web gallery builder
andy@3 7
andy@3 8 by Andy Buckley
andy@3 9 http://www.insectnation.org
andy@3 10
andy@14 11 This is a weeny script for making static sets of Web pages for presenting lots
andy@14 12 of imagey things: photos, PDFs, graphs...
andy@3 13
andy@14 14 As for the name, this is a program to make pretty crappy galleries, so it's
andy@14 15 named after a pretty crappy artist. And, thankfully, e-m-i-n is not many
andy@14 16 characters to type (and they're all close together on the Colemak keyboard
andy@14 17 layout) --- trebles all round!
andy@3 18
andy@3 19 TODO:
andy@21 20 * Make Cheetah templating optional
andy@4 21 * Try to import BeautifulSoup for validating/pretty-printing the output
andy@14 22 * Add all on one page option
andy@11 23 * Resize option
andy@11 24 * Rename option
andy@13 25 * Crop-to-thumb option
andy@16 26 * Auto-rotate by EXIF orientation
andy@13 27 * Copy Lightbox stuff into place
andy@6 28 * Allow complete rollback if any failure (or on demand?)
andy@3 29 """
andy@2 30
andy@21 31 __version__ = "0.3.3"
andy@14 32
andy@3 33
andy@5 34 import logging
andy@2 35 from optparse import OptionParser, OptionGroup
andy@14 36 parser = OptionParser(usage=__doc__, version="%prog " + __version__)
andy@14 37 parser.add_option("-t", "--title", dest="TITLE", default="",
andy@5 38 help="title of this gallery")
andy@14 39 parser.add_option("--template", dest="TEMPLATE", default=None,
andy@5 40 help="specify the template file to be used for the index pages")
andy@14 41 parser.add_option("--zipfile", dest="ZIPFILE", default=None,
andy@5 42 help="name of zip archive file. Default is based on the title.")
andy@6 43 parser.add_option("--no-zipfile", action="store_false",
andy@14 44 dest="WRITE_ZIPFILE", default=True,
andy@5 45 help="disable writing out of a zipped archive of photos from this gallery")
andy@14 46 ## TODO: Add all on one page option
andy@5 47 parser.add_option("-c", "--num-cols", dest="NUM_COLS", default=5, type=int,
andy@5 48 help="max number of thumbnail columns on one page (default: 5)")
andy@5 49 parser.add_option("-r", "--num-rows", dest="NUM_ROWS", default=6, type=int,
andy@5 50 help="max number of thumbnail rows on one page (default: 6). Set < 1 for unlimited (i.e. all on one page)")
andy@5 51 parser.add_option("--thumb-height", dest="THUMB_HEIGHT", default=150, type=int,
andy@5 52 help="thumbnail height, in pixels (default: 100)")
andy@5 53 parser.add_option("--max-imgsize", dest="MAX_IMGSIZE", default=800, type=int,
andy@5 54 help="max large image dimension in pixels (default: 800)")
andy@14 55 parser.add_option("--no-js", dest="USE_JS", action="store_false", default=True,
andy@5 56 help="disable use of funky JavaScript display stuff")
andy@14 57 parser.add_option("--force", dest="FORCE", action="store_true", default=False,
andy@5 58 help="force creation of gallery: regen thumbnails etc.")
andy@14 59 parser.add_option("--no-table", dest="USE_TABLE", action="store_false", default=True,
andy@5 60 help="don't use an HTML table for thumbnail presentation: just let the thumbs flow into the browser window")
andy@5 61 verbgroup = OptionGroup(parser, "Verbosity control")
andy@16 62 verbgroup.add_option("-v", "--verbose", action="store_const", const=logging.DEBUG, dest="LOGLEVEL",
andy@5 63 default=logging.INFO, help="print debug (very verbose) messages")
andy@16 64 verbgroup.add_option("-q", "--quiet", action="store_const", const=logging.WARNING, dest="LOGLEVEL",
andy@5 65 default=logging.INFO, help="be very quiet")
andy@5 66 parser.add_option_group(verbgroup)
andy@3 67 opts, args = parser.parse_args()
andy@5 68 logging.basicConfig(level=opts.LOGLEVEL, format="%(message)s")
andy@1 69
andy@1 70
andy@3 71 ## More stdlib imports
andy@5 72 import sys, os, glob, re, commands, math, shutil
andy@5 73 import traceback
andy@3 74
andy@3 75
andy@5 76 ## TODO: These should be options...
andy@5 77 opts.RENAME = False
andy@5 78 opts.CONVERT = False
andy@5 79
andy@5 80
andy@5 81 ## Set processing/output dir
andy@9 82 if len(args) < 1 or len(args) > 2:
andy@9 83 print parser.show_usage()
andy@9 84 exit(1)
andy@9 85 if len(args) >= 1:
andy@9 86 opts.SRCDIR = os.path.normpath(args[0])
andy@9 87 opts.OUTDIR = os.path.normpath(args[0])
andy@9 88 if len(args) == 2:
andy@9 89 opts.OUTDIR = os.path.normpath(args[1])
andy@5 90
andy@5 91
andy@5 92 ## Try to import Cheetah templating
andy@5 93 try:
andy@8 94 from Cheetah.Template import Template
andy@5 95 except Exception, e:
andy@9 96 logging.error("Couldn't import required Cheetah package")
andy@9 97 exit(1)
andy@5 98
andy@2 99 ## Try to import Python Imaging Library
andy@2 100 try:
andy@5 101 import PIL.Image as PILI
andy@2 102 except Exception, e:
andy@5 103 logging.error("Couldn't import required Python Imaging Library package")
andy@9 104 exit(1)
andy@2 105
andy@2 106
andy@3 107 def safeencode(s):
andy@2 108 """Encode a string for use as a filename."""
andy@3 109 newstr = s.replace(" ", "-").replace(",", "").replace("/", "").replace(".", "")
andy@3 110 return newstr
andy@1 111
andy@5 112 logging.debug("Title: %s" % opts.TITLE)
andy@5 113 logging.debug("Thumb height: %d" % opts.THUMB_HEIGHT)
andy@5 114
andy@1 115
andy@9 116 class ImageInfo(object):
andy@6 117 def __init__(self):
andy@9 118 self.name = None
andy@6 119 self.path = None
andy@9 120 self.thumbname = None
andy@9 121 self.thumbpath = None
andy@9 122 self.thumbx = None
andy@9 123 self.thumby = None
andy@9 124
andy@9 125 def setsize(self, sizetuple):
andy@9 126 self.thumbx = sizetuple[0]
andy@9 127 self.thumby = sizetuple[1]
andy@9 128
andy@7 129 def _getsize(self):
andy@9 130 return self.thumbx, self.thumby
andy@9 131
andy@9 132 thumbsize = property(_getsize, setsize)
andy@6 133
andy@6 134
andy@2 135 ## Go to the gallery directory and test if it's writeable
andy@2 136 if not os.access(opts.OUTDIR, os.W_OK):
andy@9 137 try:
andy@9 138 logging.info("Making output dir in %s" % opts.OUTDIR)
andy@9 139 os.makedirs(opts.OUTDIR)
andy@9 140 except Exception, e:
andy@9 141 logging.error("Problem when making output dir %s... exiting" % opts.OUTDIR)
andy@9 142 #traceback.print_exc()
andy@9 143 exit(1)
andy@1 144
andy@14 145
andy@9 146 ## Make thumbnail directory if needed
andy@9 147 opts.THUMBDIR = "thumbs"
andy@9 148 THUMBDIR = os.path.join(opts.OUTDIR, opts.THUMBDIR)
andy@5 149 try:
andy@9 150 if not os.path.isdir(THUMBDIR):
andy@9 151 logging.info("Making thumbs dir in %s" % THUMBDIR)
andy@9 152 os.makedirs(THUMBDIR)
andy@5 153 except Exception, e:
andy@5 154 logging.error("Problem when making thumbnails dir... exiting")
andy@5 155 #traceback.print_exc()
andy@9 156 exit(1)
andy@5 157
andy@2 158
andy@9 159 ## Build the list of pictures to display
andy@9 160 ## TODO: types: PNG/GIF, JPEG, PDF
andy@9 161 ## TODO: match formats & store thumb filenames
andy@9 162 EXTENSIONS = \
andy@9 163 ["*.jpg", "*.jpeg"] + \
andy@9 164 ["*.png", "*.gif"] + \
andy@9 165 ["*.tif", "*.tiff"] + \
andy@9 166 ["*.eps", "*.pdf"]
andy@9 167 imgs = []
andy@9 168 import fnmatch
andy@9 169 for img in os.listdir(opts.SRCDIR):
andy@9 170 for e in EXTENSIONS:
andy@12 171 if fnmatch.fnmatch(img.lower(), e):
andy@9 172 imgpath = os.path.join(opts.SRCDIR, img)
andy@9 173 imgs.append(imgpath)
andy@9 174 break
andy@9 175
andy@3 176 ## Count the pictures
andy@9 177 logging.debug("Number of pictures = %d" % len(imgs))
andy@9 178 if len(imgs) == 0:
andy@2 179 logging.debug("No pictures from which to build a gallery...")
andy@9 180 exit(2)
andy@9 181 logging.debug("Images: " + str(sorted(imgs)))
andy@2 182
andy@5 183
andy@9 184 ## Rename/move if needed
andy@9 185 outimgs = []
andy@9 186 for n, imgpath in enumerate(imgs):
andy@9 187 imgname = os.path.basename(imgpath)
andy@9 188 imgnameparts = os.path.splitext(imgname)
andy@9 189 targetname = imgname
andy@9 190 if opts.RENAME:
andy@9 191 targetname = "%s-%03d%s" % (safename(opts.OUTDIR), n, imgnameparts[1])
andy@9 192 targetpath = os.path.join(opts.OUTDIR, targetname)
andy@9 193 outimgs.append(targetpath)
andy@9 194 if imgpath != targetpath:
andy@9 195 logging.debug("Copying %s -> %s" % (imgpath, targetpath))
andy@9 196 import shutil
andy@9 197 shutil.copy(imgpath, targetpath)
andy@9 198
andy@9 199
andy@9 200 ## Store some image info
andy@9 201 imgsinfo = {}
andy@9 202 for picpath in outimgs:
andy@9 203 picname = os.path.basename(picpath)
andy@9 204 picbase = os.path.splitext(picname)[0]
andy@9 205
andy@9 206 ## Convert EPS, PDF, TIFF to Web-viewable formats
andy@9 207 picversions = {}
andy@9 208 picpathparts = os.path.splitext(picpath)
andy@9 209 picnameparts = os.path.splitext(picname)
andy@9 210 extn = picnameparts[1].lower()
andy@9 211 convcmd = None
andy@9 212 if extn in [".tif", ".tiff"]:
andy@9 213 picversions["TIFF"] = picname
andy@9 214 newpicname = picname + ".jpg"
andy@9 215 newpicpath = picpath + ".jpg"
andy@9 216 picversions["JPG"] = newpicname
andy@9 217 convcmd = ["convert", picpath, newpicpath]
andy@9 218 picname = newpicname
andy@9 219 picpath = newpicpath
andy@9 220 elif extn in [".eps", ".pdf"]:
andy@9 221 picversions[extn[1:].upper()] = picname
andy@9 222 newpicname = picname + ".png"
andy@9 223 newpicpath = picpath + ".png"
andy@9 224 picversions["PNG"] = newpicname
andy@10 225 convcmd = ["convert", "-density", "200", "-resize", "800x700", picpath, newpicpath]
andy@9 226 picname = newpicname
andy@9 227 picpath = newpicpath
andy@9 228 else:
andy@9 229 picversions[extn[1:].upper()] = picname
andy@9 230
andy@9 231 ## Do the conversion
andy@9 232 if convcmd:
andy@9 233 try:
andy@9 234 import subprocess
andy@9 235 subprocess.check_call(convcmd)
andy@9 236 except:
andy@9 237 raise
andy@9 238
andy@9 239 ## Main pic info
andy@9 240 info = ImageInfo()
andy@9 241 info.name = picname
andy@9 242 info.path = picpath
andy@9 243 info.versions = picversions
andy@9 244
andy@9 245 ## Thumb info
andy@9 246 ## TODO: Un-hard-code PNG thumb format
andy@9 247 thumbname = picname + ".png"
andy@9 248 thumbpath = os.path.join(THUMBDIR, thumbname)
andy@9 249 info.thumbname = thumbname
andy@9 250 info.thumbpath = thumbpath
andy@9 251
andy@9 252 ## Make thumbnail
andy@9 253 ## TODO: Be lazy!
andy@9 254 #if opts.FORCE or not os.access(thumbpath, os.R_OK) or os.stat(thumbpath).st_mtime > os.stat(pic).st_mtime:
andy@9 255 try:
andy@9 256 logging.debug("Making new thumbnail %s for %s (max height %d)" % \
andy@9 257 (thumbpath, picname, opts.THUMB_HEIGHT))
andy@9 258 thumbimg = PILI.open(picpath, "r")
andy@9 259 thumbimg.thumbnail((100000000, opts.THUMB_HEIGHT), resample=PILI.ANTIALIAS)
andy@9 260 thumbimg.save(thumbpath)
andy@9 261 info.thumbsize = thumbimg.size
andy@9 262 except Exception, e:
andy@9 263 logging.warning("Problem when making thumbnail from %s... exiting" % picpath)
andy@9 264 #traceback.print_exc()
andy@9 265 exit(1)
andy@9 266
andy@9 267 ## Store info
andy@9 268 imgsinfo[picname] = info
andy@9 269
andy@9 270
andy@9 271 #####################
andy@9 272
andy@5 273
andy@3 274 ## Calculate how many pages will be needed
andy@3 275 ## TODO: allow all on one page
andy@6 276 NUM_PER_PAGE = opts.NUM_ROWS * opts.NUM_COLS
andy@9 277 NUM_PAGES = int(math.ceil( len(imgs)/float(NUM_PER_PAGE) ))
andy@1 278
andy@1 279
andy@14 280 ## TODO: Move HTML extension-setting to option parser
andy@6 281 ## (or take from template name, e.g. page.html.template -> html)
andy@6 282 opts.EXTN = "html"
andy@6 283
andy@6 284
andy@3 285 def getPageFilename(pagenum):
andy@9 286 if pagenum == 1:
andy@3 287 pagefile = "index.%s" % opts.EXTN
andy@3 288 else:
andy@3 289 pagefile = "index%02d.%s" % (pagenum, opts.EXTN)
andy@8 290 return pagefile
andy@3 291
andy@3 292
andy@3 293 def mkPageLinkStr(pagenum):
andy@14 294 "Write the linked page list"
andy@3 295 global NUM_PAGES
andy@14 296 out = ''
andy@3 297 if NUM_PAGES > 1:
andy@6 298 out += ""
andy@3 299 ## Previous
andy@3 300 prev = pagenum - 1
andy@3 301 if prev > 0:
andy@14 302 out += '<a href="%s">prev</a>' % getPageFilename(prev)
andy@3 303 else:
andy@14 304 out += 'prev'
andy@14 305 out += '&nbsp;'
andy@3 306 ## Numbers
andy@14 307 for n in range(1, NUM_PAGES+1):
andy@3 308 if n != pagenum:
andy@14 309 out += '<a href="%s">%d</a>' % (getPageFilename(n), n)
andy@14 310 else:
andy@14 311 out += "%d" % n
andy@14 312 out += '&nbsp;'
andy@3 313 ## Next
andy@3 314 next = pagenum + 1
andy@3 315 if next <= NUM_PAGES:
andy@14 316 out += '<a href="%s">next</a>' % getPageFilename(next)
andy@3 317 else:
andy@14 318 out += 'next'
andy@3 319 return out
andy@3 320
andy@3 321
andy@9 322 ## Make a zip archive
andy@9 323 ZIPFILE = "photo-album.zip"
andy@9 324 if True: #opts.WRITE_ZIPFILE:
andy@3 325 logging.debug("Making zipped picture archive")
andy@6 326 if opts.ZIPFILE is not None:
andy@6 327 ZIPFILE = opts.ZIPFILE
andy@6 328 elif opts.TITLE is not None or len(opts.TITLE) > 0:
andy@3 329 ZIPFILE = safeencode(opts.TITLE)
andy@8 330 #ZIPFILE = safename(opts.OUTDIR)
andy@9 331 if not "." in ZIPFILE or os.path.splitextn(ZIPFILE)[1] != ".zip":
andy@6 332 ZIPFILE += ".zip"
andy@9 333 ## Do the zipping
andy@13 334 if ZIPFILE:
andy@13 335 from zipfile import ZipFile
andy@13 336 zf = ZipFile(os.path.join(opts.OUTDIR, ZIPFILE), "w")
andy@13 337 for img in imgs:
andy@13 338 zf.write(img, os.path.basename(img))
andy@13 339 zf.close()
andy@13 340 else:
andy@13 341 logging.warning("No zip file made because zip filename is empty")
andy@3 342
andy@3 343
andy@9 344 ## Copy Lightbox stuff into place
andy@9 345 #if opts.USE_JS:
andy@9 346 # from zipfile import ZipFile
andy@9 347 # zf = ZipFile(os.path.join(opts.OUTDIR, "lightbox.zip"), "r")
andy@9 348 # for img in imgs:
andy@9 349 # zf.write(img, os.path.basename(img))
andy@9 350 # zf.close()
andy@14 351
andy@9 352
andy@9 353 ## Default template
andy@9 354 tmplstr = \
andy@9 355 """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
andy@9 356 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
andy@9 357 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
andy@9 358 <head>
andy@13 359 #set title = $PAGETITLE
andy@13 360 #if $NUM_PAGES > 1
andy@13 361 #set title = $title + " (page %s)" % $PAGENUM
andy@13 362 #end if
andy@9 363 <title>$title</title>
andy@9 364 <style>
andy@13 365 img { border:0; padding:10 10 0 0; }
andy@9 366 body { padding:1em; background:white; font-family:sans-serif; }
andy@9 367 h1 { font-family:sans-serif; }
andy@13 368 a.format { text-decoration:none; font-variant:small-caps; color:grey; font-size:small; }
andy@13 369 a.format:hover { color:deeppink; }
andy@13 370 a.format:active { color:deeppink; }
andy@14 371 .pagelinks { text-decoration:none; font-variant:small-caps; color:grey; margin-top:1em; margin-bottom:1em; }
andy@14 372 .pagelinks a:link { color:#22c; text-decoration:none; }
andy@14 373 .pagelinks a:hover { color:#55c; text-decoration:none; }
andy@14 374 .pagelinks a:active { color:#55c; text-decoration:none; }
andy@9 375 </style>
andy@9 376 #if $OPTS.USE_JS:
andy@14 377 <link rel="stylesheet" href="lightbox/css/lightbox.css" type="text/css" media="screen" />
andy@9 378 <script src="lightbox/js/prototype.js" type="text/javascript"></script>
andy@9 379 <script src="lightbox/js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
andy@9 380 <script src="lightbox/js/lightbox.js" type="text/javascript"></script>
andy@9 381 #end if
andy@9 382 </head>
andy@9 383 <body>
andy@9 384 <h1>$PAGETITLE</h1>
andy@9 385 #if $NUM_PAGES > 1
andy@9 386 <div class="pagelinks">Pages: $LINKSTR</div>
andy@9 387 #end if
andy@9 388
andy@9 389 <table>
andy@9 390 <tr>
andy@9 391 #set jsrel = ''
andy@9 392 #if $OPTS.USE_JS:
andy@9 393 #set jsrel = 'rel="lightbox[emin]"'
andy@9 394 #end if
andy@9 395 #for n, thumb in enumerate($PAGEPICS)
andy@9 396 #if $n % $NUM_COLS == 0 and $n not in (0, len($PAGEPICS)-1)
andy@9 397 <tr/><tr>
andy@9 398 #end if
andy@9 399 #set info = $PICINFO[$thumb]
andy@9 400 <td>
andy@23 401 <a href="$info.relpath" $jsrel><img alt="$thumb" src="$info.relthumbpath" style="border:0;" width="$info.thumbx" height="$info.thumby" /></a><br/>
andy@9 402 #for fmt, name in $info.versions.iteritems()
andy@13 403 <a class="format" href="$name">$fmt.lower()</a>
andy@9 404 #end for
andy@9 405 </td>
andy@9 406 #end for
andy@9 407 </tr>
andy@9 408 </table>
andy@9 409
andy@9 410 #if $NUM_PAGES > 1
andy@9 411 <div class="pagelinks">Pages: $LINKSTR</div>
andy@9 412 #end if
andy@9 413
andy@13 414 #if $OPTS.WRITE_ZIPFILE and $ZIPFILE:
andy@9 415 <p>All zipped up: <a href="$ZIPFILE">$ZIPFILE</a></p>
andy@9 416 #end if
andy@9 417 </body>
andy@9 418 </html>
andy@9 419 """
andy@9 420
andy@9 421
andy@9 422 ## Override default template with a template file
andy@9 423 if opts.TEMPLATE is not None:
andy@9 424 logging.info("Using index template file %s" % opts.TEMPLATE)
andy@9 425 tf = open(opts.TEMPLATE, "r")
andy@9 426 tmplstr = tf.read()
andy@9 427 tf.close()
andy@8 428
andy@8 429
andy@3 430 ## Make each index page
andy@3 431 for n in range(NUM_PAGES):
andy@6 432 PAGENUM = n + 1
andy@3 433
andy@3 434 ## Choose and open page file
andy@14 435 PAGEFILE = getPageFilename(PAGENUM)
andy@9 436 PAGEPATH = os.path.join(opts.OUTDIR, PAGEFILE)
andy@8 437
andy@3 438 ## Write the title
andy@9 439 PAGETITLE = opts.TITLE or os.path.basename(opts.SRCDIR)
andy@14 440
andy@3 441 ## Write the linked page list
andy@8 442 LINKSTR = mkPageLinkStr(PAGENUM)
andy@14 443
andy@9 444 ## Work out the picture offsets for this page
andy@3 445 pics_start = n * NUM_PER_PAGE
andy@3 446 pics_end = (n+1) * NUM_PER_PAGE - 1
andy@9 447 if pics_end >= len(imgs):
andy@9 448 pics_end = len(imgs) - 1
andy@1 449
andy@16 450 PAGEPICS = sorted(imgsinfo.keys())[pics_start: pics_end+1]
andy@9 451 PAGEPICNUMS = range(len(PAGEPICS))
andy@9 452 relthumbdir = opts.THUMBDIR
andy@9 453 #relthumbdir = os.path.relpath(THUMBDIR, OUTDIR)
andy@9 454 reloutdir = "."
andy@9 455 for k in imgsinfo.keys():
andy@9 456 imgsinfo[k].relthumbpath = os.path.normpath(os.path.join(relthumbdir, imgsinfo[k].thumbname))
andy@9 457 imgsinfo[k].relpath = os.path.normpath(os.path.join(reloutdir, imgsinfo[k].name))
andy@9 458 PICINFO = imgsinfo
andy@9 459 # THUMBNAMES = [t.name for t in thumbsinfo.values()[pics_start : pics_end]]
andy@9 460 # print THUMBNAMES
andy@9 461 # THUMBPATHS = [os.path.join(relthumbdir, name) for name in THUMBNAMES]
andy@9 462 # print THUMBPATHS
andy@9 463 # THUMBDIMS = [t.size for t in thumbsinfo.values()[pics_start : pics_end]]
andy@1 464
andy@9 465 logging.info("Writing to index file %s" % PAGEPATH)
andy@9 466 f = open(PAGEPATH, "w")
andy@16 467 logging.debug("Images on page: %s" % PAGEPICS)
andy@8 468 tdict = {}
andy@8 469 tdict["NUM_PAGES"] = NUM_PAGES
andy@9 470 tdict["NUM_PER_PAGE"] = NUM_PER_PAGE
andy@9 471 tdict["NUM_ROWS"] = opts.NUM_ROWS
andy@9 472 tdict["NUM_COLS"] = opts.NUM_COLS
andy@8 473 tdict["PAGEPICS"] = PAGEPICS
andy@8 474 tdict["PAGENUM"] = PAGENUM
andy@8 475 tdict["PAGETITLE"] = PAGETITLE
andy@8 476 tdict["LINKSTR"] = LINKSTR
andy@8 477 tdict["PAGEPICNUMS"] = PAGEPICNUMS
andy@9 478 tdict["PICINFO"] = imgsinfo
andy@9 479 # tdict["THUMBS"] = thumbsinfo
andy@9 480 # tdict["THUMBNAMES"] = THUMBNAMES
andy@9 481 # tdict["THUMBPATHS"] = THUMBPATHS
andy@9 482 # tdict["THUMBDIMS"] = THUMBDIMS
andy@8 483 tdict["ZIPFILE"] = ZIPFILE
andy@8 484 tdict["OPTS"] = opts
andy@8 485 indexstr = Template(tmplstr, searchList=[tdict])
andy@9 486 #print indexstr
andy@8 487 f.write(str(indexstr))
andy@3 488 f.close()
andy@3 489
andy@3 490 ## It's over. Nothing to see here.
andy@3 491 logging.debug("All done!")

mercurial