PythonSlideShow

walkfs-writemarkup.py

6:c69af778e9a3
2010-08-26 ink changed template_H5p10n.html to use vertical CSS transitions instead of horizontal ones.
     1 #!/usr/bin/env python     2 # -*- coding: utf-8 -*-     3      4 from os import walk, path, stat     5 from sha import new     6 #from time import      7      8 # Bug: Class attributes end up with white space (if filenames have them): this might be a bug or a feature, I suppose.     9     10 # Put template loader from file minimumWorking... mod with %s at slide insertion point.    11 # Setup a current slideset, current index display (re-add it modified from original).    12     13 def makeSlides(root):    14    defaultOrder, slideData = "", ""    15    for current, directories, files in walk(root):    16 #      print current, directories, files    17       classes = ""    18       if directories != []:    19          for directory in directories:    20             try:    21                fullpath = path.join(current, directory)    22                uid = new(fullpath).hexdigest()    23                metaInfo = stat(fullpath) # see http://wiki.forum.nokia.com/index.php/How_to_handle_file_metadata    24                slideData += '\n<!-- directory --><DIV class="slide %s" id="%s">%s</DIV>' % ("defaultOrder", uid, metaInfo)    25                defaultOrder += " " + uid    26             except:    27                pass    28     29       if files != []:    30          for filename in files:    31             #classes stay the same for file slides as for directory slides for each path given.    32             try:    33                fullpath = path.join(current, filename)     34                uid = new(fullpath).hexdigest()    35                metaInfo = stat(fullpath)    36                slideData += '\n<!-- filename --><DIV class="slide %s" id="%s">%s</DIV>' % ("defaultOrder", uid, metaInfo)    37                defaultOrder += " " + uid    38             except:    39                pass    40    slideOrder = '\n<!-- default order --><DIV class="%s">\n%s\n</DIV>' % ("sequencing defaultOrder", defaultOrder)    41    slideData += slideOrder       42     43    return slideData    44     45 s = makeSlides('.')    46 template = file("./template_H5p10n.html", "r").read()    47 r = template.split("%s")    48 t = r[0] + s + r[1]    49 file("./generated_slides", "w").write(t)