Chromium Code Reviews| Index: build/util/remove_tree.py |
| diff --git a/build/util/remove_tree.py b/build/util/remove_tree.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1977834725d392235c06da80aa3b8a7bb66d7d1e |
| --- /dev/null |
| +++ b/build/util/remove_tree.py |
| @@ -0,0 +1,29 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2013 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. |
| + |
| +""" |
| +remove_tree.py -- Remove the specified directory recursively |
| +""" |
| + |
| +import os |
| +import shutil |
| +import sys |
| + |
| +def main(argv=None): |
|
Isaac (away)
2013/08/28 06:22:56
make option required
hajimehoshi
2013/08/28 06:47:15
Done.
|
| + if argv is None: |
| + argv = sys.argv |
|
Isaac (away)
2013/08/28 06:22:56
remove these lines
hajimehoshi
2013/08/28 06:47:15
Done.
|
| + |
| + if len(argv) != 2: |
|
Isaac (away)
2013/08/28 06:22:56
return 'Usage: %s <PATH>' % os.path.basename(__fil
Isaac (away)
2013/08/28 06:24:18
Actually you should use:
return 'Usage: %s <PATH>
hajimehoshi
2013/08/28 06:47:15
Done.
|
| + program = os.path.basename(__file__) |
| + sys.stderr.write('Usage: ' + program + ' PATH\n') |
| + sys.exit(1) |
|
Isaac (away)
2013/08/28 06:22:56
remove these lines
hajimehoshi
2013/08/28 06:47:15
Done.
|
| + |
| + path = argv[1] |
| + shutil.rmtree(path, True) |
| + |
| + return 0 |
|
Isaac (away)
2013/08/28 06:22:56
Not needed, sys.exit(None) exits with zero, remove
hajimehoshi
2013/08/28 06:47:15
Done.
|
| + |
| +if __name__ == '__main__': |
| + sys.exit(main()) |
|
Isaac (away)
2013/08/28 06:22:56
pass sys.argv here
hajimehoshi
2013/08/28 06:47:15
Done.
|