Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2967)

Unified Diff: bootstrap/remove_orphaned_pycs.py

Issue 1200843003: Added virtualenv for depot_tools (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix on Windows Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: bootstrap/remove_orphaned_pycs.py
diff --git a/bootstrap/remove_orphaned_pycs.py b/bootstrap/remove_orphaned_pycs.py
new file mode 100755
index 0000000000000000000000000000000000000000..9091b9b7943a90096abc4f882fac10df7d55510b
--- /dev/null
+++ b/bootstrap/remove_orphaned_pycs.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# Copyright (c) 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+import os
+import sys
+
+
+def main(argv):
+ logging.basicConfig(level=logging.DEBUG)
+ if len(argv) == 0:
+ bootstrap_dir = os.path.dirname(os.path.abspath(__file__))
+ infra_dir = os.path.dirname(bootstrap_dir)
+ argv = [infra_dir]
+
+ for root in argv:
+ # This could take an argument, except gclient DEPS has no good way to pass
+ # us an argument, and gclient getcwd() is ../ from our .gclient file. :(
+ logging.debug("Cleaning orphaned *.pyc files from: %s" % root)
+
+ for (dirpath, _, filenames) in os.walk(root):
+ fnset = set(filenames)
+ for filename in filenames:
+ if filename.endswith(".pyc") and filename[:-1] not in fnset:
+ path = os.path.join(dirpath, filename)
+ logging.info("Deleting orphan *.pyc file: %s" % path)
+ os.remove(path)
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))

Powered by Google App Engine
This is Rietveld 408576698