source: trunk/clean_all.py @ 8587

Last change on this file since 8587 was 7753, checked in by hudson, 14 years ago

Moved anuga_core into trunk.

File size: 1.7 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                       
22                     
23# Data files (may be recovered from repository with svn up)
24extensions_to_delete += ['.tms',
25                         #'.tsh',
26                         '.msh',
27                         '.pts',
28                         '.xml',
29                         '.png']
30
31
32filenames_to_delete = []   
33for dirpath, dirnames, filenames in os.walk('.'):
34
35    print 'Searching dir', dirpath
36   
37    if '.svn' in dirnames:
38        dirnames.remove('.svn')  # don't visit SVN directories
39
40
41    for filename in filenames:
42        for ext in extensions_to_delete:
43            if filename.endswith(ext):
44                absname = os.path.join(dirpath, filename)
45                print '  Flagged for deletion', absname
46                filenames_to_delete.append(absname)   
47
48
49print 
50N = len(filenames_to_delete)             
51if N > 0:
52    msg = '%d files flagged for deletion. Proceed? (Y/N)[N]' %N
53    answer = raw_input(msg)
54   
55    if answer.lower() == 'y':
56        for filename in filenames_to_delete:
57            print 'Deleting', filename
58            os.remove(filename)
59           
60        print 'You may wish to run "svn up" to recover important data files'   
61    else:
62        print 'Nothing deleted'
63else:
64    print 'No files flagged for deletion'           
65
66
67
Note: See TracBrowser for help on using the repository browser.