source: clean_all.py @ 5453

Last change on this file since 5453 was 5128, checked in by ole, 15 years ago

Added .stdout to clean_all.py

File size: 1.3 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                        '.sww',
20                        '.stdout']
21                        #'.png']
22
23filenames_to_delete = []   
24for dirpath, dirnames, filenames in os.walk('.'):
25
26    print 'Searching dir', dirpath
27   
28    if '.svn' in dirnames:
29        dirnames.remove('.svn')  # don't visit SVN directories
30
31
32    for filename in filenames:
33        for ext in extensions_to_delete:
34            if filename.endswith(ext):
35                absname = os.path.join(dirpath, filename)
36                print '  Flagged for deletion', absname
37                filenames_to_delete.append(absname)   
38
39
40print 
41N = len(filenames_to_delete)             
42if N > 0:
43    msg = '%d files flagged for deletion. Proceed? (Y/N)[N]' %N
44    answer = raw_input(msg)
45   
46    if answer.lower() == 'y':
47        for filename in filenames_to_delete:
48            print 'Deleting', filename
49            os.remove(filename)
50    else:
51        print 'Nothing deleted'
52else:
53    print 'No files flagged for deletion'           
54
55
56
Note: See TracBrowser for help on using the repository browser.