Just van Rossum | 7f1653c | 1999-02-07 16:36:22 +0000 | [diff] [blame] | 1 | """ ***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 | |
| 14 | import macfs |
Jack Jansen | b340acf | 2003-01-26 21:40:00 +0000 | [diff] [blame] | 15 | import EasyDialogs |
Just van Rossum | 7f1653c | 1999-02-07 16:36:22 +0000 | [diff] [blame] | 16 | import os |
| 17 | import sys |
| 18 | import re |
| 19 | |
| 20 | sweepfiletypes = [ |
| 21 | 'APPL', # applications |
| 22 | 'Atmp', # applet template |
| 23 | 'shlb', # shared libs |
| 24 | 'MPSY', # SYM and xSYM files |
| 25 | 'PYC ', # .pyc files |
| 26 | ] |
| 27 | |
| 28 | sweepfolderre = re.compile(r"(.*) Data$") |
| 29 | |
| 30 | |
| 31 | def 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 | |
| 39 | def 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 Jansen | b340acf | 2003-01-26 21:40:00 +0000 | [diff] [blame] | 57 | pathname = EasyDialogs.AskFolder(message="Please locate the Python home directory") |
| 58 | if pathname: |
| 59 | walk(pathname) |
Just van Rossum | 7f1653c | 1999-02-07 16:36:22 +0000 | [diff] [blame] | 60 | sys.exit(1) # so we see the results |