summaryrefslogtreecommitdiffstats
path: root/tools/generate-gperfs.py
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2023-07-17 19:06:40 +0200
committerFrantisek Sumsal <frantisek@sumsal.cz>2023-08-10 18:13:29 +0200
commit782051f3cbb3d70bf322277354fa0ccbc6fc2cb2 (patch)
tree7fe7a8cf6853f4dd311b2cde083935f50e0cf6e7 /tools/generate-gperfs.py
parenttools: pylint dbus_exporter.py (diff)
downloadsystemd-782051f3cbb3d70bf322277354fa0ccbc6fc2cb2.tar.xz
systemd-782051f3cbb3d70bf322277354fa0ccbc6fc2cb2.zip
tools: pylint generate-gperfs.py
Diffstat (limited to '')
-rwxr-xr-xtools/generate-gperfs.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/generate-gperfs.py b/tools/generate-gperfs.py
index d240b2c383..3887bb6ee9 100755
--- a/tools/generate-gperfs.py
+++ b/tools/generate-gperfs.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# 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
@@ -7,18 +8,22 @@ Generate %-from-name.gperf from %-list.txt
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')
-print("""\
+ name, prefix, file = sys.argv[1:]
+
+ print("""\
%{
#if __GNUC__ >= 7
_Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"")
#endif
%}""")
-print("""\
-struct {}_name {{ const char* name; int id; }};
+ print(f"""\
+struct {name}_name {{ const char* name; int id; }};
%null-strings
-%%""".format(name))
+%%""")
-for line in open(input):
- print("{0}, {1}{0}".format(line.rstrip(), prefix))
+ for line in open(file):
+ print("{0}, {1}{0}".format(line.rstrip(), prefix))