rm_output.py.html CLAWPACK  
 Source file:   rm_output.py
 Directory:   /Users/rjl/git/rjleveque/clawpack-4.6.3/python
 Converted:   Mon Jan 21 2013 at 20:16:06   using clawcode2html
 This documentation file will not reflect any later changes in the source file.

 
"""
Performs 'rm -rf _output' in each subdirectory of the specified directory.
"""

import os,sys,glob

def make_clean(rootdir):

    if rootdir==[]:   
        # if called from command line with no argument
        clawdir = os.path.expandvars('$CLAW')
        rootdir = clawdir
    else:
        # called with an argument, try to use this for rootdir:
        rootdir = rootdir[0]
        rootdir = os.path.abspath(rootdir)
    
    print "Will execute 'rm -rf _output' in every subdirectory of "
    print "    ", rootdir
    ans = raw_input("Ok? ")
    if ans.lower() not in ['y','yes']:
        print "Aborting."
        sys.exit()
    
    os.chdir(rootdir)
    
    for (dirpath, subdirs, files) in os.walk('.'):
        currentdir = os.path.abspath(os.getcwd())
        os.chdir(os.path.abspath(dirpath))
        
        if os.path.isfile('Makefile'):
            print 'In directory ',dirpath
            try:
                os.system('rm -rf _output')
            except:
                pass
            
        os.chdir(currentdir)
        

if __name__=='__main__':
    make_clean(sys.argv[1:])