Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools: add a script to download Unicode data files, and rename grapheme_break_property_data_gen.py to unicode_properties_data_gen.py #4435

Merged
merged 5 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stl/inc/__msvc_format_ucd_tables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// WARNING, this entire header is generated by
// tools/unicode_properties_parse/grapheme_break_property_data_gen.py
// tools/unicode_properties_parse/unicode_properties_data_gen.py
// DO NOT MODIFY!

// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
Expand Down Expand Up @@ -112,7 +112,7 @@ struct _Unicode_property_data {
// The enums containing the values for the properties are also generated, in order to ensure they match
// up correctly with how we're parsing them.
//
// All sets of data tables are generated by tools/unicode_properties_parse/grapheme_break_property_data_gen.py in the
// All sets of data tables are generated by tools/unicode_properties_parse/unicode_properties_data_gen.py in the
// https://github.com/microsoft/stl repository.
//
// The data format is a set of arrays for each character property. The first is an array of uint32_t encoding
Expand Down
23 changes: 23 additions & 0 deletions tools/unicode_properties_parse/download_unicode_data_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from urllib.request import urlretrieve
StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved


Unicode_data_files = {
"DerivedCoreProperties.txt": "https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt",
"DerivedGeneralCategory.txt": "https://www.unicode.org/Public/UCD/latest/ucd/extracted/DerivedGeneralCategory.txt",
"EastAsianWidth.txt": "https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt",
"GraphemeBreakProperty.txt": "https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt",
"GraphemeBreakTest.txt": "https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt",
"emoji-data.txt": "https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt",
}
Comment on lines +7 to +14

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it desirable that these pull data from the latest available UCD files? That complicates rerunning the scripts with the intention to match what might have been downloaded previously. If it is intentional, perhaps rename the script to download_latest_unicode_data_files.py. Otherwise, the files specific to Unicode 15.1.0 (for example) are available at https://unicode.org/Public/15.1.0/ucd. Another alternative would be to allow a base Unicode version URL to be supplied on the command line.


def download_unicode_data_files():
for filename, url in Unicode_data_files.items():
print(f"downloading {filename} from {url}")
urlretrieve(url, filename)


if __name__ == "__main__":
download_unicode_data_files()
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def line_to_cpp_data_line_utf8(line: BreakTestItem) -> str:


"""
Generate test data from "GraphemeBreakText.txt"
Generate test data from "GraphemeBreakTest.txt"
This file can be downloaded from: https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt
This script looks for GraphemeBreakTest.txt in same directory as this script
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def compact_property_ranges(input: list[PropertyRange]) -> list[PropertyRange]:
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

// WARNING, this entire header is generated by
// tools/unicode_properties_parse/grapheme_break_property_data_gen.py
// tools/unicode_properties_parse/unicode_properties_data_gen.py
// DO NOT MODIFY!

// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
Expand Down Expand Up @@ -201,7 +201,7 @@ def compact_property_ranges(input: list[PropertyRange]) -> list[PropertyRange]:
// The enums containing the values for the properties are also generated, in order to ensure they match
// up correctly with how we're parsing them.
//
// All sets of data tables are generated by tools/unicode_properties_parse/grapheme_break_property_data_gen.py in the
// All sets of data tables are generated by tools/unicode_properties_parse/unicode_properties_data_gen.py in the
// https://github.com/microsoft/stl repository.
//
// The data format is a set of arrays for each character property. The first is an array of uint32_t encoding
Expand Down