OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import logging |
| 7 import os |
| 8 import sys |
| 9 |
| 10 |
| 11 def main(argv): |
| 12 logging.basicConfig(level=logging.DEBUG) |
| 13 if len(argv) == 0: |
| 14 bootstrap_dir = os.path.dirname(os.path.abspath(__file__)) |
| 15 infra_dir = os.path.dirname(bootstrap_dir) |
| 16 argv = [infra_dir] |
| 17 |
| 18 for root in argv: |
| 19 # This could take an argument, except gclient DEPS has no good way to pass |
| 20 # us an argument, and gclient getcwd() is ../ from our .gclient file. :( |
| 21 logging.debug("Cleaning orphaned *.pyc files from: %s" % root) |
| 22 |
| 23 for (dirpath, _, filenames) in os.walk(root): |
| 24 fnset = set(filenames) |
| 25 for filename in filenames: |
| 26 if filename.endswith(".pyc") and filename[:-1] not in fnset: |
| 27 path = os.path.join(dirpath, filename) |
| 28 logging.info("Deleting orphan *.pyc file: %s" % path) |
| 29 os.remove(path) |
| 30 |
| 31 |
| 32 if __name__ == '__main__': |
| 33 sys.exit(main(sys.argv[1:])) |
OLD | NEW |