[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/25] scripts/modules/module_block: Use Python 3 interpreter & ad
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 05/25] scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main |
Date: |
Sun, 31 May 2020 18:38:26 +0200 |
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20200512103238.7078-6-philmd@redhat.com>
---
scripts/modules/module_block.py | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/scripts/modules/module_block.py b/scripts/modules/module_block.py
index f23191fac1..1109df827d 100644
--- a/scripts/modules/module_block.py
+++ b/scripts/modules/module_block.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
#
# Module information generator
#
@@ -80,19 +80,20 @@ def print_bottom(fheader):
#endif
''')
-# First argument: output file
-# All other arguments: modules source files (.c)
-output_file = sys.argv[1]
-with open(output_file, 'w') as fheader:
- print_top(fheader)
+if __name__ == '__main__':
+ # First argument: output file
+ # All other arguments: modules source files (.c)
+ output_file = sys.argv[1]
+ with open(output_file, 'w') as fheader:
+ print_top(fheader)
- for filename in sys.argv[2:]:
- if os.path.isfile(filename):
- process_file(fheader, filename)
- else:
- print("File " + filename + " does not exist.", file=sys.stderr)
- sys.exit(1)
+ for filename in sys.argv[2:]:
+ if os.path.isfile(filename):
+ process_file(fheader, filename)
+ else:
+ print("File " + filename + " does not exist.", file=sys.stderr)
+ sys.exit(1)
- print_bottom(fheader)
+ print_bottom(fheader)
-sys.exit(0)
+ sys.exit(0)
--
2.21.3
- [PULL 00/25] python-next patches for 2020-05-31, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 01/25] scripts/qemugdb: Remove shebang header, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 02/25] scripts/qemu-gdb: Use Python 3 interpreter, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 03/25] scripts/qmp: Use Python 3 interpreter, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 04/25] scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main(), Philippe Mathieu-Daudé, 2020/05/31
- [PULL 05/25] scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main,
Philippe Mathieu-Daudé <=
- [PULL 06/25] scripts/qmp: Fix shebang and imports, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 07/25] python: remove more instances of sys.version_info, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 08/25] python/qemu/machine: add kill() method, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 09/25] python/qemu/machine: remove logging configuration, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 10/25] python/qemu: delint and add pylintrc, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 11/25] python/qemu: delint; add flake8 config, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 12/25] python/qemu: remove Python2 style super() calls, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 13/25] python/qemu: fix socket.makefile() typing, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 14/25] python/qemu: Adjust traceback typing, Philippe Mathieu-Daudé, 2020/05/31
- [PULL 15/25] python/qemu/qmp: use True/False for non/blocking modes, Philippe Mathieu-Daudé, 2020/05/31