mirror of https://github.com/python/cpython
Patch by Russel Owen: if we have command line arguments zap pyc files
in the directories given.
This commit is contained in:
parent
dc391a67e3
commit
f1148f0bb3
|
@ -1,23 +1,26 @@
|
||||||
# Zap .pyc files
|
#!/usr/local/bin/python
|
||||||
|
"""Recursively zap all .pyc files"""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
# set doit true to actually delete files
|
||||||
|
# set doit false to just print what would be deleted
|
||||||
doit = 1
|
doit = 1
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if os.name == 'mac':
|
if not sys.argv[1:]:
|
||||||
import macfs
|
if os.name == 'mac':
|
||||||
fss, ok = macfs.GetDirectory('Directory to zap pyc files in')
|
import macfs
|
||||||
if not ok:
|
fss, ok = macfs.GetDirectory('Directory to zap pyc files in')
|
||||||
sys.exit(0)
|
if not ok:
|
||||||
dir = fss.as_pathname()
|
sys.exit(0)
|
||||||
zappyc(dir)
|
dir = fss.as_pathname()
|
||||||
else:
|
zappyc(dir)
|
||||||
if not sys.argv[1:]:
|
else:
|
||||||
print 'Usage: zappyc dir ...'
|
print 'Usage: zappyc dir ...'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
for dir in sys.argv[1:]:
|
for dir in sys.argv[1:]:
|
||||||
zappyc(dir)
|
zappyc(dir)
|
||||||
|
|
||||||
def zappyc(dir):
|
def zappyc(dir):
|
||||||
os.path.walk(dir, walker, None)
|
os.path.walk(dir, walker, None)
|
||||||
|
|
Loading…
Reference in New Issue