Staging
v0.5.1
https://github.com/python/cpython
Revision fb5d378a65166d9d75d9fb0bc84ca945026a088e authored by Fred Drake on 31 March 2003, 16:45:22 UTC, committed by Fred Drake on 31 March 2003, 16:45:22 UTC
1 parent b9ea876
Raw File
Tip revision: fb5d378a65166d9d75d9fb0bc84ca945026a088e authored by Fred Drake on 31 March 2003, 16:45:22 UTC
Match some of the markup changes from the trunk.
Tip revision: fb5d378
rmpyc.py
# 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"
back to top