| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Copies test data files or directories into a given output directory.""" | 6 """Copies test data files or directories into a given output directory.""" |
| 7 | 7 |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import shutil | 10 import shutil |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 class WrongNumberOfArgumentsException(Exception): | 13 class WrongNumberOfArgumentsException(Exception): |
| 14 pass | 14 pass |
| 15 | 15 |
| 16 def ListFilesForPath(path): | 16 def ListFilesForPath(path): |
| 17 """Returns a list of all the files under a given path.""" | 17 """Returns a list of all the files under a given path.""" |
| 18 output = [] | 18 output = [] |
| 19 # Ignore dotfiles and dot directories. | 19 # Ignore revision control metadata directories. |
| 20 # TODO(rohitrao): This will fail to exclude cases where the initial argument | 20 if (os.path.basename(path).startswith('.git') or |
| 21 # is a relative path that starts with a dot. | 21 os.path.basename(path).startswith('.svn')): |
| 22 if os.path.basename(path).startswith('.'): | |
| 23 return output | 22 return output |
| 24 | 23 |
| 25 # Files get returned without modification. | 24 # Files get returned without modification. |
| 26 if not os.path.isdir(path): | 25 if not os.path.isdir(path): |
| 27 output.append(path) | 26 output.append(path) |
| 28 return output | 27 return output |
| 29 | 28 |
| 30 # Directories get recursively expanded. | 29 # Directories get recursively expanded. |
| 31 contents = os.listdir(path) | 30 contents = os.listdir(path) |
| 32 for item in contents: | 31 for item in contents: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 result = DoMain(argv[1:]) | 94 result = DoMain(argv[1:]) |
| 96 except WrongNumberOfArgumentsException, e: | 95 except WrongNumberOfArgumentsException, e: |
| 97 print >>sys.stderr, e | 96 print >>sys.stderr, e |
| 98 return 1 | 97 return 1 |
| 99 if result: | 98 if result: |
| 100 print result | 99 print result |
| 101 return 0 | 100 return 0 |
| 102 | 101 |
| 103 if __name__ == '__main__': | 102 if __name__ == '__main__': |
| 104 sys.exit(main(sys.argv)) | 103 sys.exit(main(sys.argv)) |
| OLD | NEW |