summaryrefslogtreecommitdiffstats
path: root/PCbuild/rmpyc.py
diff options
context:
space:
mode:
Diffstat (limited to 'PCbuild/rmpyc.py')
-rw-r--r--PCbuild/rmpyc.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/PCbuild/rmpyc.py b/PCbuild/rmpyc.py
new file mode 100644
index 0000000..019c69b
--- /dev/null
+++ b/PCbuild/rmpyc.py
@@ -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"