OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import os |
| 6 import pipes |
| 7 import sys |
| 8 |
| 9 def GetSources(dirname): |
| 10 """Returns a quoted list of source files. |
| 11 |
| 12 Args: |
| 13 dirname: A (possibly relative) path to the directory holding sources in |
| 14 question. |
| 15 |
| 16 Returns: |
| 17 A list of filenames. Items in the list will be quoted if needed. |
| 18 """ |
| 19 sources = [] |
| 20 for root, dirs, files in os.walk(dirname): |
| 21 for file in files: |
| 22 if file != 'OWNERS' and os.path.splitext(file)[1] != '.pyc': |
| 23 sources.append(pipes.quote(os.path.join(root, file).replace('\\', '/'))) |
| 24 return sources |
| 25 |
| 26 |
| 27 def DoMain(args): |
| 28 """Returns a space-separated list of source files. |
| 29 |
| 30 Args: |
| 31 args: An agument list, the first item of which is the directory to scan. |
| 32 |
| 33 Returns: |
| 34 A string containing a space-separated list of source files. |
| 35 """ |
| 36 return ' '.join(GetSources(args[0])) |
| 37 |
| 38 |
| 39 def main(args): |
| 40 """Prints the sources in a directory. |
| 41 |
| 42 Args: |
| 43 args: An argument list, the first item of which is the directory to scan. |
| 44 """ |
| 45 sys.stdout.write('\n'.join(GetSources(args[0]))) |
| 46 return 0 |
| 47 |
| 48 |
| 49 if __name__ == '__main__': |
| 50 sys.exit(main(sys.argv[1:])) |
OLD | NEW |