#!/usr/bin/env python
# A script to remove hidden files (created by gedit) and compiled Python files
# preparatory to bundling the site software.
#
# Last modified 01 March 2013 by Michael Malicoat.

import fnmatch, os

def remove(filename):
    print "Removing \"" + filename + "\"...",
    os.unlink(filename)
    print "done"

def remove_extraneous_files():
    for dirpath, dirnames, filenames in os.walk("."):
        for file in filenames:
            fullpath = os.path.join(dirpath, file)
            if fnmatch.fnmatch(file, '*~'):
                remove(fullpath)
      
            elif fnmatch.fnmatch(file, '*.pyc'):
                remove(fullpath)

def clear_cached_views():
    for filename in os.listdir("./views/cache"):
        remove("./views/cache/" + filename)
        
remove_extraneous_files()
clear_cached_views()

