[libc++][Android] Allow testing libc++ with clang-r536225 (#116149)
[llvm-project.git] / libc / newhdrgen / yaml_functions_sorted.py
blobb960ecaf973f52df18457089f23b057049bfc5e2
1 # ex: python3 sort_yaml_functions.py
2 # ex: must be within yaml directory
3 import yaml
4 import os
7 def sort_yaml_functions(yaml_file):
8 with open(yaml_file, "r") as f:
9 yaml_data = yaml.safe_load(f)
11 if "functions" in yaml_data:
12 yaml_data["functions"].sort(key=lambda x: x["name"])
14 class IndentYamlListDumper(yaml.Dumper):
15 def increase_indent(self, flow=False, indentless=False):
16 return super(IndentYamlListDumper, self).increase_indent(flow, False)
18 with open(yaml_file, "w") as f:
19 yaml.dump(
20 yaml_data,
22 Dumper=IndentYamlListDumper,
23 default_flow_style=False,
24 sort_keys=False,
28 def main():
29 current_directory = os.getcwd()
30 yaml_files = [
31 file for file in os.listdir(current_directory) if file.endswith(".yaml")
34 for yaml_file in yaml_files:
35 sort_yaml_functions(yaml_file)
38 if __name__ == "__main__":
39 main()