ยปCore Development>Code coverage>PCbuild/rmpyc.py

Python code coverage for PCbuild/rmpyc.py

#countcontent
1n/a# Remove all the .pyc and .pyo files under ../Lib.
2n/a
3n/a
4n/adef deltree(root):
5n/a import os
6n/a from os.path import join
7n/a
8n/a npyc = npyo = 0
9n/a for root, dirs, files in os.walk(root):
10n/a for name in files:
11n/a delete = False
12n/a if name.endswith('.pyc'):
13n/a delete = True
14n/a npyc += 1
15n/a elif name.endswith('.pyo'):
16n/a delete = True
17n/a npyo += 1
18n/a
19n/a if delete:
20n/a os.remove(join(root, name))
21n/a
22n/a return npyc, npyo
23n/a
24n/anpyc, npyo = deltree("../Lib")
25n/aprint(npyc, ".pyc deleted,", npyo, ".pyo deleted")