diff options
| author | David Brazdil <dbrazdil@google.com> | 2018-09-06 14:46:55 +0100 |
|---|---|---|
| committer | David Brazdil <dbrazdil@google.com> | 2018-09-06 15:10:28 +0100 |
| commit | ae88d4e21e072a5a4a15777ce2575b90a4689333 (patch) | |
| tree | cf0d7dbec4ac0d9c4e7f3406016e997559a31c66 /tools/hiddenapi/generate_hiddenapi_lists.py | |
| parent | 081a589ad997e30062bfb9c6cd18f77d9cae0245 (diff) | |
Ignore comment lines in hidden api lists
It is sometimes useful to add comments at the top of a source file. This
patch changes hidden API list generation to ignore lines beginning with
a hash.
Note that due to the sorting constraints on hidden API lists, comments
can be only at the top of the files.
Test: m appcompat
Change-Id: I1bc6fd44d1b1f10a5adc45093d7f7ed5a0c5a54f
Diffstat (limited to 'tools/hiddenapi/generate_hiddenapi_lists.py')
| -rwxr-xr-x | tools/hiddenapi/generate_hiddenapi_lists.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/hiddenapi/generate_hiddenapi_lists.py b/tools/hiddenapi/generate_hiddenapi_lists.py index ec72ecee2a5c..c5fcb63624c5 100755 --- a/tools/hiddenapi/generate_hiddenapi_lists.py +++ b/tools/hiddenapi/generate_hiddenapi_lists.py @@ -62,6 +62,8 @@ def get_args(): def read_lines(filename): """Reads entire file and return it as a list of lines. + Lines which begin with a hash are ignored. + Args: filename (string): Path to the file to read from. @@ -69,7 +71,7 @@ def read_lines(filename): list: Lines of the loaded file as a list of strings. """ with open(filename, 'r') as f: - return f.readlines() + return filter(lambda line: not line.startswith('#'), f.readlines()) def write_lines(filename, lines): """Writes list of lines into a file, overwriting the file it it exists. |
