PythonSlideShow

walkfs-writemarkup.py

9:5b81e83a114f
2010-09-02 ink changed README
     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 def directorySlides(root):     9    content = ""    10    for current, directories, files in walk(root):    11       for count in current.split("/"):    12          content += '\n<DIV class="directory" id="%s">%s' % (current, current)    13          if directories != []:    14             for item in directories:    15                fullpath = path.join(current, item)    16                content += '\n  <DIV class="subdirectory" id="%s">%s</DIV>' % (item, fullpath)    17          else:    18             print "No directories in %s" % current    19 #No cnotent is shown for nested slides, and this is a big problem    20          if files != []:    21             for item in files:    22                fullpath = path.join(current, item)    23                content += '\n  <DIV class="file" id="%s">%s</DIV>' % (item, fullpath)    24          else:    25             print "No files in %s" % current    26          content += '\n</DIV>'    27     28    return content    29     30 def main():    31    s = directorySlides("./")    32    template = file("./template_H5p10n.html", "r").read()    33    r = template.split("%s")    34    t = r[0] + s + r[1]    35    file("./generated_slides", "w").write(t)    36        37 activation = main()