OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 |
| 3 """Usage: interface_node_path.py directory-path text_file |
| 4 |
| 5 The goal of this script is to integrate IDL file path under the directory to tex
t file. |
| 6 """ |
| 7 import os |
| 8 import sys |
| 9 |
| 10 _IDL_SUFFIX = '.idl' |
| 11 _NON_IDL_FILES = frozenset([ |
| 12 'InspectorInstrumentation.idl', |
| 13 ]) |
| 14 |
| 15 |
| 16 def get_idl_files(path): |
| 17 """Return a generator which has absolute path of IDL files. |
| 18 Args: |
| 19 path: directory path |
| 20 Return: |
| 21 generator, absolute IDL file path |
| 22 """ |
| 23 for dir_path, dir_names, file_names in os.walk(path): |
| 24 for file_name in file_names: |
| 25 if file_name.endswith(_IDL_SUFFIX) and file_name not in _NON_IDL_FIL
ES: |
| 26 yield os.path.join(dir_path, file_name) |
| 27 |
| 28 |
| 29 def main(args): |
| 30 path = args[0] |
| 31 filename = args[1] |
| 32 with open(filename, 'w') as f: |
| 33 for filepath in get_idl_files(path): |
| 34 f.write(filepath + '\n') |
| 35 |
| 36 |
| 37 if __name__ == '__main__': |
| 38 main(sys.argv[1:]) |
OLD | NEW |