mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
tools: pylint generate-gperfs.py
This commit is contained in:
parent
8b1932cf2d
commit
782051f3cb
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
# pylint: disable=unbalanced-tuple-unpacking,consider-using-f-string,consider-using-with
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Generate %-from-name.gperf from %-list.txt
|
Generate %-from-name.gperf from %-list.txt
|
||||||
@ -7,7 +8,11 @@ Generate %-from-name.gperf from %-list.txt
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
name, prefix, input = sys.argv[1:]
|
if __name__ == '__main__':
|
||||||
|
if len(sys.argv) != 4:
|
||||||
|
sys.exit(f'Usage: {sys.argv[0]} name prefix file')
|
||||||
|
|
||||||
|
name, prefix, file = sys.argv[1:]
|
||||||
|
|
||||||
print("""\
|
print("""\
|
||||||
%{
|
%{
|
||||||
@ -15,10 +20,10 @@ print("""\
|
|||||||
_Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"")
|
_Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"")
|
||||||
#endif
|
#endif
|
||||||
%}""")
|
%}""")
|
||||||
print("""\
|
print(f"""\
|
||||||
struct {}_name {{ const char* name; int id; }};
|
struct {name}_name {{ const char* name; int id; }};
|
||||||
%null-strings
|
%null-strings
|
||||||
%%""".format(name))
|
%%""")
|
||||||
|
|
||||||
for line in open(input):
|
for line in open(file):
|
||||||
print("{0}, {1}{0}".format(line.rstrip(), prefix))
|
print("{0}, {1}{0}".format(line.rstrip(), prefix))
|
||||||
|
Loading…
Reference in New Issue
Block a user