Chromium Code Reviews| Index: Source/bindings/scripts/interface_node_path.py |
| diff --git a/Source/bindings/scripts/interface_node_path.py b/Source/bindings/scripts/interface_node_path.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f92d3bf36e14ffc6ae09ad8585b710950f70a822 |
| --- /dev/null |
| +++ b/Source/bindings/scripts/interface_node_path.py |
| @@ -0,0 +1,37 @@ |
| +#!/usr/bin/env python |
| + |
| +""" |
| +The goal of this script is to integrate IDL file path under the directory to text file. |
|
bashi
2015/09/02 05:17:37
Please describe a typical usage here. Developers t
|
| +""" |
| +import os |
| +import sys |
| + |
| + |
| +def get_idl_files(path): |
| + """ |
|
bashi
2015/09/02 05:17:37
Please add one line summary as shiino-san suggeste
|
| + Args: |
| + path: directory path |
| + Return: |
| + str, absolute IDL file path |
|
bashi
2015/09/02 05:17:37
This function returns a generator, not a str.
|
| + """ |
| + file_type = '.idl' |
| + non_idl_set = ( |
| + 'InspectorInstrumentation.idl', |
| + ) |
|
bashi
2015/09/02 05:17:37
Let move |file_type| and |non_idl_set| out from th
|
| + for dir_path, dir_names, file_names in os.walk(path): |
| + for file_name in file_names: |
| + if file_name.endswith(file_type) and file_name not in non_idl_set: |
| + yield os.path.join(dir_path, file_name) |
| + |
| + |
| +def main(args): |
| + path = args[0] |
| + filename = args[1] |
| + f = open(filename, 'w') |
|
bashi
2015/09/02 05:17:37
How about:
with open(filename, 'w') as f:
.
|
| + for filepath in get_idl_files(path): |
| + f.write(filepath + '\n') |
| + f.close() |
| + |
| + |
| +if __name__ == '__main__': |
| + main(sys.argv[1:]) |