Skip to content

Commit f735b90

Browse files
committed
dd
Signed-off-by: Ralph Castain <[email protected]>
1 parent a699543 commit f735b90

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

src/util/convert-help.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -286,20 +286,9 @@ def purge(parsed_data, citations):
286286
def generate_c_code(parsed_data):
287287
# Generate C code with an array of filenames and their
288288
# corresponding INI sections.
289-
c_code = f"""// THIS FILE IS GENERATED AUTOMATICALLY! EDITS WILL BE LOST!
290-
// This file generated by {os.path.basename(sys.argv[0])}
289+
c_code = "// THIS FILE IS GENERATED AUTOMATICALLY! EDITS WILL BE LOST!\n// This file generated by " + os.path.basename(sys.argv[0]) + "\n\n"
291290

292-
"""
293-
# Rather than escaping the C code {} in f strings, make this a
294-
# separate (non-f-string) addition to c_code.
295-
c_code += """#include "src/include/pmix_config.h"
296-
297-
#include <stdio.h>
298-
#include <string.h>
299-
300-
#include "src/include/pmix_globals.h"
301-
302-
"""
291+
c_code += "#include \"src/include/pmix_config.h\"\n#include <stdio.h>\n#include <string.h>\n\n#include \"src/include/pmix_globals.h\"\n\n"
303292

304293
ini_arrays = []
305294
file_entries = []
@@ -309,18 +298,18 @@ def generate_c_code(parsed_data):
309298

310299
ini_entries = []
311300
for section, content_list in sections.items():
312-
entry = f' {{ .topic = "{section}",\n .content = (const char *[]){{\n'
301+
entry = " { .topic = \"" + section + "\",\n .content = (const char *[]){\n"
313302
for content in content_list:
314303
c_content = content.replace('"','\\"').replace("\n", '\\n"\n"').replace("\\;", ";")
315-
entry += f' \"{c_content}\",\n'
316-
entry += f' NULL}}\n }},\n'
304+
entry += " \"" + c_content + "\",\n"
305+
entry += " NULL}\n },\n"
317306
ini_entries.append(entry)
318-
ini_entries.append(f' {{ .topic = NULL, .content = NULL }}')
307+
ini_entries.append(" { .topic = NULL, .content = NULL }")
319308

320-
ini_array_name = f"ini_entries_{idx}"
321-
ini_arrays.append(f"static pmix_show_help_entry_t {ini_array_name}[] = {{\n" + "\n".join(ini_entries) + "\n};\n")
322-
file_entries.append(f' {{ "{filename}", {ini_array_name} }}')
323-
file_entries.append(f' {{ NULL, NULL }}')
309+
ini_array_name = "ini_entries_" + str(idx)
310+
ini_arrays.append("static pmix_show_help_entry_t " + ini_array_name + "[] = {\n" + "\n".join(ini_entries) + "\n};\n")
311+
file_entries.append(" { \"" + filename + "\", " + ini_array_name + "}")
312+
file_entries.append(" { NULL, NULL }")
324313

325314
c_code += "\n".join(ini_arrays) + "\n"
326315
c_code += "pmix_show_help_file_t pmix_show_help_data[] = {\n" + ",\n".join(file_entries) + "\n};\n"

0 commit comments

Comments
 (0)