diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-01-23 22:45:52 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-01-23 22:45:52 (GMT) |
commit | dfebb2786a2b5a3c122ea3ca9f009515affef8d3 (patch) | |
tree | 6c68f060ae05c79b0ffb37212d7af907bbda6da5 /Mac | |
parent | 3236f6ad8cafa78a096024d5b2c10ec224e0c1b4 (diff) | |
download | cpython-dfebb2786a2b5a3c122ea3ca9f009515affef8d3.zip cpython-dfebb2786a2b5a3c122ea3ca9f009515affef8d3.tar.gz cpython-dfebb2786a2b5a3c122ea3ca9f009515affef8d3.tar.bz2 |
Ah well, why not check this in. A script to remove all .pyc files in a folder hierarchy.
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/scripts/zappycfiles.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Mac/scripts/zappycfiles.py b/Mac/scripts/zappycfiles.py new file mode 100644 index 0000000..dbe95b6 --- /dev/null +++ b/Mac/scripts/zappycfiles.py @@ -0,0 +1,35 @@ +# Zap .pyc files +import os +import sys + +doit = 1 + +def main(): + if os.name == 'mac': + import macfs + fss, ok = macfs.GetDirectory('Directory to zap pyc files in') + if not ok: + sys.exit(0) + dir = fss.as_pathname() + zappyc(dir) + else: + if not sys.argv[1:]: + print 'Usage: zappyc dir ...' + sys.exit(1) + for dir in sys.argv[1:]: + zappyc(dir) + +def zappyc(dir): + os.path.walk(dir, walker, None) + +def walker(dummy, top, names): + for name in names: + if name[-4:] == '.pyc': + path = os.path.join(top, name) + print 'Zapping', path + if doit: + os.unlink(path) + +if __name__ == '__main__': + main() + |