PythonSlideShow

Changeset

2:6847b03caa25
2010-08-26 ink raw files shortlog changelog graph Added walkfs-writemarkup.py to keep this part separate until I get it right.
walkfs-writemarkup.py (file)
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/walkfs-writemarkup.py	Thu Aug 26 09:53:53 2010 +0300
     1.3 @@ -0,0 +1,37 @@
     1.4 +#!/usr/bin/env python
     1.5 +# -*- coding: utf-8 -*-
     1.6 +
     1.7 +from os import walk, path
     1.8 +from sha import new
     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 +def makeSlides(root):
    1.13 +   slideData = ""
    1.14 +   for current, directories, files in walk(root):
    1.15 +      print "\n" + current, directories, files
    1.16 +      classes = ""
    1.17 +      if directories != []:
    1.18 +         for directory in directories:
    1.19 +            try:
    1.20 +               uid = new(path.join(current, directory)).hexdigest()
    1.21 +               metaInfo = path.join(current, directory)
    1.22 +               slideData += '\n<!-- directory --><DIV class="%s" id="%s">%s</DIV>' % (classes, uid, metaInfo)
    1.23 +            except:
    1.24 +               pass
    1.25 +
    1.26 +      if files != []:
    1.27 +         for filename in files:
    1.28 +            #classes stay the same for file slides as for directory slides for each path given.
    1.29 +            try:
    1.30 +               uid = new(path.join(current, filename)).hexdigest()
    1.31 +               metaInfo = path.join(current, filename)
    1.32 +               slideData += '\n<!-- filename --><DIV class="%s" id="%s">%s</DIV>' % (classes, uid, metaInfo)
    1.33 +            except:
    1.34 +               pass
    1.35 +
    1.36 +
    1.37 +   return slideData
    1.38 +
    1.39 +s = makeSlides('.')
    1.40 +file("./generated_slides", "w").write(s)