~ubuntu-branches/ubuntu/maverick/python3.1/maverick

« back to all changes in this revision

Viewing changes to PC/VS7.1/rmpyc.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-03-23 00:01:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090323000127-5fstfxju4ufrhthq
Tags: upstream-3.1~a1+20090322
ImportĀ upstreamĀ versionĀ 3.1~a1+20090322

Show diffs side-by-side

added added

removed removed

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