summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNan Zhou <nanzhoumails@gmail.com>2022-09-20 21:12:13 +0300
committerEd Tanous <ed@tanous.net>2022-09-21 20:01:12 +0300
commit043bec0965b9e9ba55888440fec4588c28335e5c (patch)
tree7061051c77ef6c3b76e408f18ccf16fc34bcec35 /scripts
parent3590bd1dee5a0e56d4d282f0a1e3cf2c8804dfa1 (diff)
downloadbmcweb-043bec0965b9e9ba55888440fec4588c28335e5c.tar.xz
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 <nanzhoumails@gmail.com> Change-Id: If18de0d9f89088f9b5732613ecf59520650bb11a
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/parse_registries.py29
1 files changed, 15 insertions, 14 deletions
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 <registries.hpp>
// 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 <privileges.hpp>
+
+// 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 <privileges.hpp>\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"]: