From 043bec0965b9e9ba55888440fec4588c28335e5c Mon Sep 17 00:00:00 2001 From: Nan Zhou Date: Tue, 20 Sep 2022 18:12:13 +0000 Subject: privilege registry: simplify writing headers This patch reused similar patterns in |REGISTRY_HEADER| so that the python code is more readable. It also moved the clang-format off macro and warning a bit in so they are all consistent with each other. Tested: code compiles. Signed-off-by: Nan Zhou Change-Id: If18de0d9f89088f9b5732613ecf59520650bb11a --- scripts/parse_registries.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'scripts') diff --git a/scripts/parse_registries.py b/scripts/parse_registries.py index de560d80bb..8c300eda2e 100755 --- a/scripts/parse_registries.py +++ b/scripts/parse_registries.py @@ -4,6 +4,9 @@ import os import requests +PRAGMA_ONCE = '''#pragma once +''' + WARNING = '''/**************************************************************** * READ THIS WARNING FIRST * This is an auto-generated header which contains definitions @@ -15,8 +18,7 @@ WARNING = '''/**************************************************************** * github organization. ***************************************************************/''' -REGISTRY_HEADER = WARNING + ''' -#pragma once +REGISTRY_HEADER = PRAGMA_ONCE + WARNING + ''' #include // clang-format off @@ -163,23 +165,22 @@ def get_variable_name_for_privilege_set(privilege_list): return "Or".join(names) +PRIVILEGE_HEADER = PRAGMA_ONCE + WARNING + ''' +#include + +// clang-format off + +namespace redfish::privileges +{ +''' + + def make_privilege_registry(): path, json_file, type_name, url = \ make_getter('Redfish_1.3.0_PrivilegeRegistry.json', 'privilege_registry.hpp', 'privilege') with open(path, 'w') as registry: - registry.write( - "#pragma once\n" - "{WARNING}\n" - "// clang-format off\n" - "\n" - "#include \n" - "\n" - "namespace redfish::privileges\n" - "{{\n" - .format( - WARNING=WARNING, - filename=os.path.basename(path))) + registry.write(PRIVILEGE_HEADER) privilege_dict = {} for mapping in json_file["Mappings"]: -- cgit v1.2.3