Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6a9aec4

Browse files
committed
Change Windows test to do a complete job of removing .pyc/.pyo files
reachable from Lib/.
1 parent d2c1abe commit 6a9aec4

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

PCbuild/rmpyc.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Remove all the .pyc and .pyo files under ../Lib.
2+
3+
def deltree(root):
4+
import os
5+
def rm(path):
6+
os.unlink(path)
7+
npyc = npyo = 0
8+
dirs = [root]
9+
while dirs:
10+
dir = dirs.pop()
11+
for short in os.listdir(dir):
12+
full = os.path.join(dir, short)
13+
if os.path.isdir(full):
14+
dirs.append(full)
15+
elif short.endswith(".pyc"):
16+
npyc += 1
17+
rm(full)
18+
elif short.endswith(".pyo"):
19+
npyo += 1
20+
rm(full)
21+
return npyc, npyo
22+
23+
npyc, npyo = deltree("../Lib")
24+
print npyc, ".pyc deleted,", npyo, ".pyo deleted"

PCbuild/rt.bat

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
@if "%1"=="-d" goto Again
2222
@if "%_qmode%"=="yes" goto Qmode
2323
@echo Deleting .pyc/.pyo files ...
24-
@del ..\Lib\*.pyc
25-
@del ..\Lib\*.pyo
26-
@del ..\Lib\test\*.pyc
27-
@del ..\Lib\test\*.pyo
24+
@%_exe% rmpyc.py
2825
%_exe% %_dashO% ../lib/test/regrtest.py %1 %2 %3 %4 %5 %6 %7 %8 %9
2926
@echo About to run again without deleting .pyc/.pyo first:
3027
@pause

0 commit comments

Comments
 (0)