The 0.5 release happened on 2/15, not on 2/14. :-)
[python/dscho.git] / Mac / scripts / makeclean.py
blob005ea02ede2fbec9caa752955323521665bf7a3e
1 """ ***DANGEROUS***
2 script to remove
3 all results of a
4 build process.
6 ***Don't***
7 run this if you are
8 ***not***
9 building Python
10 from the source
11 !!!
12 """
14 import macfs
15 import os
16 import sys
17 import re
19 sweepfiletypes = [
20 'APPL', # applications
21 'Atmp', # applet template
22 'shlb', # shared libs
23 'MPSY', # SYM and xSYM files
24 'PYC ', # .pyc files
27 sweepfolderre = re.compile(r"(.*) Data$")
30 def 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)
38 def 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)
56 fss, ok = macfs.GetDirectory("Please locate the Python home directory")
57 if ok:
58 walk(fss.as_pathname())
59 sys.exit(1) # so we see the results