Staging
v0.5.1
https://github.com/python/cpython
Revision bd5bcf6d432ca289aedc340c90066d629fef9e7f authored by Tim Peters on 10 January 2002, 22:42:17 UTC, committed by Tim Peters on 10 January 2002, 22:42:17 UTC
1 parent f521ae1
Raw File
Tip revision: bd5bcf6d432ca289aedc340c90066d629fef9e7f authored by Tim Peters on 10 January 2002, 22:42:17 UTC
More backporting of 32-bit installer. Doesn't work yet, but getting
Tip revision: bd5bcf6
rmpyc.py
# Remove all the .pyc and .pyo files under ../Lib.

from __future__ import nested_scopes

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"
back to top