source: anuga_core/clean_all.py @ 3871

Last change on this file since 3871 was 3772, checked in by ole, 18 years ago

Added script to recursively clean computer generated garbage

File size: 1.2 KB
Line 
1"""Remove computer generated garbage such as
2
3   *.py~
4   *.pyc
5   *.o   
6   *.so
7   *.dll
8
9Note: Recompile ANUGA after running this script
10"""
11
12import os
13
14
15extensions_to_delete = ['~',
16                        '.pyc',       # Python
17                        '.o', '.so', '.dll',  # C
18                        '.aux', '.ps']        # LaTeX
19
20filenames_to_delete = []   
21for dirpath, dirnames, filenames in os.walk('.'):
22
23    print 'Searching dir', dirpath
24   
25    if '.svn' in dirnames:
26        dirnames.remove('.svn')  # don't visit SVN directories
27
28
29    for filename in filenames:
30        for ext in extensions_to_delete:
31            if filename.endswith(ext):
32                absname = os.path.join(dirpath, filename)
33                print '  Flagged for deletion', absname
34                filenames_to_delete.append(absname)   
35
36
37print 
38N = len(filenames_to_delete)             
39if N > 0:
40    msg = '%d files flagged for deletion. Proceed? (Y/N)[N]' %N
41    answer = raw_input(msg)
42   
43    if answer.lower() == 'y':
44        for filename in filenames_to_delete:
45            print 'Deleting', filename
46            os.remove(filename)
47    else:
48        print 'Nothing deleted'
49else:
50    print 'No files flagged for deletion'           
51
52
53
Note: See TracBrowser for help on using the repository browser.