]> granicus.if.org Git - python/commitdiff
Patch by Russel Owen: if we have command line arguments zap pyc files
authorJack Jansen <jack.jansen@cwi.nl>
Fri, 9 Aug 2002 10:17:28 +0000 (10:17 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Fri, 9 Aug 2002 10:17:28 +0000 (10:17 +0000)
in the directories given.

Mac/scripts/zappycfiles.py

index dbe95b674ac56d9418a5a342ea3b0eef943c9d4d..22a021cab2ffa3369afc1433d0eb2286576b7c98 100644 (file)
@@ -1,23 +1,26 @@
-# Zap .pyc files
+#!/usr/local/bin/python
+"""Recursively zap all .pyc files"""
 import os
 import sys
 
+# set doit true to actually delete files
+# set doit false to just print what would be deleted
 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:]:
+       if not sys.argv[1:]:
+               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:
                        print 'Usage: zappyc dir ...'
                        sys.exit(1)
-               for dir in sys.argv[1:]:
-                       zappyc(dir)
+       for dir in sys.argv[1:]:
+               zappyc(dir)
 
 def zappyc(dir):
        os.path.walk(dir, walker, None)