Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2013 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 """ | |
| 7 remove_tree.py -- Remove the specified directory recursively | |
| 8 """ | |
| 9 | |
| 10 import os | |
| 11 import shutil | |
| 12 import sys | |
| 13 | |
| 14 def main(argv=None): | |
|
Isaac (away)
2013/08/28 06:22:56
make option required
hajimehoshi
2013/08/28 06:47:15
Done.
| |
| 15 if argv is None: | |
| 16 argv = sys.argv | |
|
Isaac (away)
2013/08/28 06:22:56
remove these lines
hajimehoshi
2013/08/28 06:47:15
Done.
| |
| 17 | |
| 18 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.
| |
| 19 program = os.path.basename(__file__) | |
| 20 sys.stderr.write('Usage: ' + program + ' PATH\n') | |
| 21 sys.exit(1) | |
|
Isaac (away)
2013/08/28 06:22:56
remove these lines
hajimehoshi
2013/08/28 06:47:15
Done.
| |
| 22 | |
| 23 path = argv[1] | |
| 24 shutil.rmtree(path, True) | |
| 25 | |
| 26 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.
| |
| 27 | |
| 28 if __name__ == '__main__': | |
| 29 sys.exit(main()) | |
|
Isaac (away)
2013/08/28 06:22:56
pass sys.argv here
hajimehoshi
2013/08/28 06:47:15
Done.
| |
| OLD | NEW |