#!/usr/bin/env python

import sys
import os
import numpy


def make_index(scene_root, scene_dir, verbose=False):

    title = scene_root

    files = ''
    for filename in os.listdir(scene_dir):
        if 'thumb' in filename:
            continue
        if filename == 'index.html':
            continue

        files += '<li><a href="%s">%s</a></li>\n' % (filename, filename)
        
    src_dir = os.path.dirname(__file__)
    doc = open(src_dir + '/index_template.html').read()
    doc = doc.replace('@@@TITLE@@@', title)
    doc = doc.replace('@@@FILES@@@', files)
    doc = doc.replace('@@@SCENE_ROOT@@@', scene_root)
    open(scene_dir + '/index.html','w').write(doc)

if __name__ == '__main__':

    if len(sys.argv) < 3:
        print 'Usage: scene_index_maker.py <scene_root> <scene_dir_path>'
        sys.exit(1)

    make_index(sys.argv[1], sys.argv[2])

    

@@ -51,17 +51,16 @@
  numpy%0A%0A
-%0A
 def make
@@ -300,16 +300,250 @@
 ntinue%0A%0A
+        filesize = os.path.getsize(os.path.join(scene_dir,filename))%0A%0A        if filesize %3E 100000:%0A            nice_size = ' (%25.1fMB)' %25 (filesize / 1048576.0)%0A        else:%0A            nice_size = ' (%25.1fKB)' %25 (filesize / 1024.0)%0A%0A
         
@@ -584,15 +584,30 @@
 /li%3E
+%25s
 %5Cn' %25 (
+%0A            
 file
@@ -620,16 +620,27 @@
 filename
+, nice_size
 )%0A      

add user readable file size in index.html