PythonSlideShow

Change of walkfs-writemarkup.py

5:12b106f3967c
walkfs-writemarkup.py
     1.1 --- a/walkfs-writemarkup.py	Thu Aug 26 10:19:48 2010 +0300
     1.2 +++ b/walkfs-writemarkup.py	Thu Aug 26 14:56:43 2010 +0300
     1.3 @@ -3,14 +3,17 @@
     1.4  
     1.5  from os import walk, path, stat
     1.6  from sha import new
     1.7 -from time import 
     1.8 +#from time import 
     1.9  
    1.10  # Bug: Class attributes end up with white space (if filenames have them): this might be a bug or a feature, I suppose.
    1.11  
    1.12 +# Put template loader from file minimumWorking... mod with %s at slide insertion point.
    1.13 +# Setup a current slideset, current index display (re-add it modified from original).
    1.14 +
    1.15  def makeSlides(root):
    1.16     defaultOrder, slideData = "", ""
    1.17     for current, directories, files in walk(root):
    1.18 -      print current, directories, files
    1.19 +#      print current, directories, files
    1.20        classes = ""
    1.21        if directories != []:
    1.22           for directory in directories:
    1.23 @@ -18,7 +21,7 @@
    1.24                 fullpath = path.join(current, directory)
    1.25                 uid = new(fullpath).hexdigest()
    1.26                 metaInfo = stat(fullpath) # see http://wiki.forum.nokia.com/index.php/How_to_handle_file_metadata
    1.27 -               slideData += '\n<!-- directory --><DIV class="%s" id="%s">%s</DIV>' % (classes, uid, metaInfo)
    1.28 +               slideData += '\n<!-- directory --><DIV class="slide %s" id="%s">%s</DIV>' % ("defaultOrder", uid, metaInfo)
    1.29                 defaultOrder += " " + uid
    1.30              except:
    1.31                 pass
    1.32 @@ -30,14 +33,17 @@
    1.33                 fullpath = path.join(current, filename) 
    1.34                 uid = new(fullpath).hexdigest()
    1.35                 metaInfo = stat(fullpath)
    1.36 -               slideData += '\n<!-- filename --><DIV class="%s" id="%s">%s</DIV>' % (classes, uid, metaInfo)
    1.37 +               slideData += '\n<!-- filename --><DIV class="slide %s" id="%s">%s</DIV>' % ("defaultOrder", uid, metaInfo)
    1.38                 defaultOrder += " " + uid
    1.39              except:
    1.40                 pass
    1.41 -   slideOrder = '\n<!-- default order --><DIV class="%s">The default slide order is this DIV\'s class attribute.</DIV>' % defaultOrder
    1.42 +   slideOrder = '\n<!-- default order --><DIV class="%s">\n%s\n</DIV>' % ("sequencing defaultOrder", defaultOrder)
    1.43     slideData += slideOrder   
    1.44  
    1.45     return slideData
    1.46  
    1.47  s = makeSlides('.')
    1.48 -file("./generated_slides", "w").write(s)
    1.49 +template = file("./template_H5p10n.html", "r").read()
    1.50 +r = template.split("%s")
    1.51 +t = r[0] + s + r[1]
    1.52 +file("./generated_slides", "w").write(t)