]> granicus.if.org Git - python/commitdiff
Change Windows test to do a complete job of removing .pyc/.pyo files
authorTim Peters <tim.peters@gmail.com>
Sun, 11 Feb 2001 00:46:39 +0000 (00:46 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 11 Feb 2001 00:46:39 +0000 (00:46 +0000)
reachable from Lib/.

PCbuild/rmpyc.py [new file with mode: 0644]
PCbuild/rt.bat

diff --git a/PCbuild/rmpyc.py b/PCbuild/rmpyc.py
new file mode 100644 (file)
index 0000000..019c69b
--- /dev/null
@@ -0,0 +1,24 @@
+# Remove all the .pyc and .pyo files under ../Lib.
+
+def deltree(root):
+    import os
+    def rm(path):
+        os.unlink(path)
+    npyc = npyo = 0
+    dirs = [root]
+    while dirs:
+        dir = dirs.pop()
+        for short in os.listdir(dir):
+            full = os.path.join(dir, short)
+            if os.path.isdir(full):
+                dirs.append(full)
+            elif short.endswith(".pyc"):
+                npyc += 1
+                rm(full)
+            elif short.endswith(".pyo"):
+                npyo += 1
+                rm(full)
+    return npyc, npyo
+
+npyc, npyo = deltree("../Lib")
+print npyc, ".pyc deleted,", npyo, ".pyo deleted"
index 4a4c97ec2e7c0c303ccd4fc38c9eb206cd3c8dfc..1d2829f1c67b7ec052a7dade1db53d8d1b0c03a6 100755 (executable)
 @if "%1"=="-d" goto Again
 @if "%_qmode%"=="yes" goto Qmode
 @echo Deleting .pyc/.pyo files ...
-@del ..\Lib\*.pyc
-@del ..\Lib\*.pyo
-@del ..\Lib\test\*.pyc
-@del ..\Lib\test\*.pyo
+@%_exe% rmpyc.py
 %_exe% %_dashO% ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9
 @echo About to run again without deleting .pyc/.pyo first:
 @pause