[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 5/6] scripts/modules/module_block: Use Python 3 interpreter &
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v4 5/6] scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main |
Date: |
Tue, 12 May 2020 12:32:37 +0200 |
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
scripts/modules/module_block.py | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/scripts/modules/module_block.py b/scripts/modules/module_block.py
index f23191fac1..2e7021b952 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
#
@@ -10,7 +10,6 @@
# This work is licensed under the terms of the GNU GPL, version 2.
# See the COPYING file in the top-level directory.
-import sys
import os
def get_string_struct(line):
@@ -80,19 +79,21 @@ 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__':
+ import sys
+ # 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
- [PATCH v4 0/6] scripts: More Python fixes, Philippe Mathieu-Daudé, 2020/05/12
- [PATCH v4 1/6] scripts/qemugdb: Remove shebang header, Philippe Mathieu-Daudé, 2020/05/12
- [PATCH v4 2/6] scripts/qemu-gdb: Use Python 3 interpreter, Philippe Mathieu-Daudé, 2020/05/12
- [PATCH v4 3/6] scripts/qmp: Use Python 3 interpreter, Philippe Mathieu-Daudé, 2020/05/12
- [PATCH v4 4/6] scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main(), Philippe Mathieu-Daudé, 2020/05/12
- [PATCH v4 5/6] scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main,
Philippe Mathieu-Daudé <=
- [PATCH v4 6/6] tests/migration/guestperf: Use Python 3 interpreter, Philippe Mathieu-Daudé, 2020/05/12
- Re: [PATCH v4 0/6] scripts: More Python fixes, Kevin Wolf, 2020/05/12
- Re: [PATCH v4 0/6] scripts: More Python fixes, Philippe Mathieu-Daudé, 2020/05/29