diff options
author | Victor Chang <vichang@google.com> | 2021-08-02 15:06:35 +0100 |
---|---|---|
committer | Victor Chang <vichang@google.com> | 2021-08-03 11:13:02 +0100 |
commit | 9ec19cbbd0e52e0f253c7355959ec62772541702 (patch) | |
tree | fc8f74c24743859cc54df69b6b549875dfc2bd77 | |
parent | 3a0a95301b68479e42600be28fc78a74e9acb6ce (diff) | |
download | icu-9ec19cbbd0e52e0f253c7355959ec62772541702.tar.gz |
Use some python3 constructs in generate_ndk.py script
Bug: 168242257
Test: Verified no generated content change.
Change-Id: I5ede89a8c218d8e62056c8b780b365a674dd3886
-rwxr-xr-x | tools/icu4c_srcgen/generate_ndk.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/tools/icu4c_srcgen/generate_ndk.py b/tools/icu4c_srcgen/generate_ndk.py index dcf5685c3..570cafbbc 100755 --- a/tools/icu4c_srcgen/generate_ndk.py +++ b/tools/icu4c_srcgen/generate_ndk.py @@ -222,20 +222,16 @@ DOXYGEN_ALIASES = { def add_ndk_required_doxygen_grouping(): """Add @addtogroup annotation to the header files for NDK API docs""" path = android_path('external/icu/libicu/ndk_headers/unicode') - files = [os.path.join(path, f) for f in Path(path).glob("*.h")] + files = Path(path).glob("*.h") for src_path in files: - with open(src_path, 'r') as file: - header_content = file.read() + header_content = src_path.read_text() for old, new in DOXYGEN_ALIASES.items(): header_content = header_content.replace(old, new) - with open(src_path, 'w') as file: - file.write(header_content) + src_path.write_text(header_content) - - for src_path in files: if os.path.basename(src_path) in IGNORED_HEADER_FOR_DOXYGEN_GROUPING: continue @@ -249,7 +245,8 @@ def add_ndk_required_doxygen_grouping(): # Next iteration if the above sed regex doesn't add the text if not has_string_in_file(src_path, 'addtogroup'): - print('Warning: unicode/%s has no "\\file" annotation' % os.path.basename(src_path)) + basename = os.path.basename(src_path) + print(f'Warning: unicode/{basename} has no "\\file" annotation') continue # Add the closing bracket for @addtogroup |