#!/usr/bin/env python # # index_gen.py # Laszlo Szathmary, 2011 (jabba.laci@gmail.com) # # Project's home page: # https://pythonadventures.wordpress.com/2011/03/26/static-html-filelist-generator/ # # Version: 0.1 # Date: 2011-03-26 (yyyy-mm-dd) # # This free software is copyleft licensed under the same terms as Python, or, # at your option, under version 2 of the GPL license. # # James Crofts July 2011: # Now under the GNU General Public License, version 2 # # Modified to exclude hidden directories such as .svn, .git, etc. # Added support for multiple directories as arguments # Other modifications for use in CryptoNAS development import os import os.path import sys import re ofile = None class SimpleHtmlFilelistGenerator: # start from this directory base_dirs = None exclude_re = None def __init__(self, dirs): self.base_dirs = dirs # Ignore "hidden" filenames, .pyc files, and help and documentation locations self.exclude_re = re.compile("(\..*)|(.*\.pyc)|(.*~)|(intl)|(help)") def print_html_header(self): ofile.write("""
""",) def print_html_footer(self): ofile.write('' + '\n')
home = 'https://pythonadventures.wordpress.com/2011/03/26/static-html-filelist-generator/'
name = 'Static HTML Filelist Generator'
ofile.write('
' + '\n')
href = "%s" % (home, name)
ofile.write("
""",)
def processDirectory ( self, args, dirname, filenames):
#For each name in filenames, if it matches exclude_re, delete it from the list in-place
ofile.write('' + dirname + '/' + '' + '' + '\n')
os.path.walk(base_dir, self.processDirectory, None )
ofile.write('
' + '\n')
ofile.write('