blob: 14416abb27c03dcce779e908dd324ac9d7ab5f76 [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
Jack Jansenb340acf2003-01-26 21:40:00 +000015import EasyDialogs
Just van Rossum7f1653c1999-02-07 16:36:22 +000016import os
17import sys
18import re
19
20sweepfiletypes = [
21 'APPL', # applications
22 'Atmp', # applet template
23 'shlb', # shared libs
24 'MPSY', # SYM and xSYM files
25 'PYC ', # .pyc files
26 ]
27
28sweepfolderre = re.compile(r"(.*) Data$")
29
30
31def remove(top):
32 if os.path.isdir(top):
33 for name in os.listdir(top):
34 path = os.path.join(top, name)
35 remove(path)
36 os.remove(top)
37
38
39def walk(top):
40 if os.path.isdir(top):
41 m = sweepfolderre.match(top)
42 if m and os.path.exists(m.group(1) + ".prj"):
43 print "removing folder:", top
44 remove(top)
45 else:
46 for name in os.listdir(top):
47 path = os.path.join(top, name)
48 walk(path)
49 else:
50 fss = macfs.FSSpec(top)
51 cr, tp = fss.GetCreatorType()
52 if tp in sweepfiletypes and top <> sys.executable:
53 print "removing file: ", top
54 remove(top)
55
56
Jack Jansenb340acf2003-01-26 21:40:00 +000057pathname = EasyDialogs.AskFolder(message="Please locate the Python home directory")
58if pathname:
59 walk(pathname)
Just van Rossum7f1653c1999-02-07 16:36:22 +000060 sys.exit(1) # so we see the results