blob: 005ea02ede2fbec9caa752955323521665bf7a3e [file] [log] [blame]
Just van Rossum7f1653c1999-02-07 16:36:22 +00001""" ***DANGEROUS***
2 script to remove
3 all results of a
4 build process.
5
6 ***Don't***
7 run this if you are
8 ***not***
9 building Python
10 from the source
11 !!!
12"""
13
14import macfs
15import os
16import sys
17import re
18
19sweepfiletypes = [
20 'APPL', # applications
21 'Atmp', # applet template
22 'shlb', # shared libs
23 'MPSY', # SYM and xSYM files
24 'PYC ', # .pyc files
25 ]
26
27sweepfolderre = re.compile(r"(.*) Data$")
28
29
30def remove(top):
31 if os.path.isdir(top):
32 for name in os.listdir(top):
33 path = os.path.join(top, name)
34 remove(path)
35 os.remove(top)
36
37
38def walk(top):
39 if os.path.isdir(top):
40 m = sweepfolderre.match(top)
41 if m and os.path.exists(m.group(1) + ".prj"):
42 print "removing folder:", top
43 remove(top)
44 else:
45 for name in os.listdir(top):
46 path = os.path.join(top, name)
47 walk(path)
48 else:
49 fss = macfs.FSSpec(top)
50 cr, tp = fss.GetCreatorType()
51 if tp in sweepfiletypes and top <> sys.executable:
52 print "removing file: ", top
53 remove(top)
54
55
56fss, ok = macfs.GetDirectory("Please locate the Python home directory")
57if ok:
58 walk(fss.as_pathname())
59 sys.exit(1) # so we see the results