Turn a file into a list of split lines. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- scripts/group-qemu-caps.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index ca5f9b7247..2eaaf06bb4 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -27,15 +27,19 @@ import subprocess import sys -def load_caps_flags(filename, start_regex, end_regex): - capsflags = [] +def load_file(filename): lines = [] + with open(filename, "r") as fh: + lines = fh.read().splitlines() + + return lines + + +def load_caps_flags(lines, start_regex, end_regex): + capsflags = [] start = 0 end = 0 - with open(filename, "r") as fh: - lines = fh.read().splitlines() - for idx, line in enumerate(lines): if re.search(start_regex, line): start = idx @@ -132,7 +136,8 @@ errs = False header_path = args.prefix + 'src/qemu/qemu_capabilities.h' source_path = args.prefix + 'src/qemu/qemu_capabilities.c' -capsflags = load_caps_flags(header_path, +header_lines = load_file(header_path) +capsflags = load_caps_flags(header_lines, r'virQEMUCapsFlags grouping marker', r'QEMU_CAPS_LAST \/\* this must') -- 2.31.1