Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2f36b3e commit 8b7beb6Copy full SHA for 8b7beb6
1 file changed
PCbuild/rmpyc.py
@@ -1,23 +1,24 @@
1
# Remove all the .pyc and .pyo files under ../Lib.
2
3
+
4
def deltree(root):
5
import os
- def rm(path):
6
- os.unlink(path)
+ from os.path import join
7
8
npyc = npyo = 0
- 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"):
+ for root, dirs, files in os.walk(root):
+ for name in files:
+ delete = False
+ if name.endswith('.pyc'):
+ delete = True
16
npyc += 1
17
- rm(full)
18
- elif short.endswith(".pyo"):
+ elif name.endswith('.pyo'):
19
npyo += 1
20
+ if delete:
+ os.remove(join(root, name))
21
22
return npyc, npyo
23
24
npyc, npyo = deltree("../Lib")
0 commit comments