Separate file loading from its parsing.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
scripts/group-qemu-caps.py | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py
index 3581d1545a..a43cd1de45 100755
--- a/scripts/group-qemu-caps.py
+++ b/scripts/group-qemu-caps.py
@@ -27,8 +27,7 @@ import subprocess
import sys
-def load_caps_flags(filename, start_str, end_str):
- capsflags = []
+def load_file(filename, start_str, end_str):
lines = []
start = 0
end = 0
@@ -43,7 +42,13 @@ def load_caps_flags(filename, start_str, end_str):
end = idx
break
- for line in lines[start:end]:
+ return (lines, start, end)
+
+
+def load_caps_flags(lines):
+ capsflags = []
+
+ for line in lines:
if re.search(r'''.*/\* [0-9]+ \*/.*''', line):
continue
if re.search(r'''^\s*$''', line):
@@ -135,9 +140,10 @@ args = parser.parse_args()
errs = False
-capsflags = load_caps_flags(args.prefix + 'src/qemu/qemu_capabilities.h',
- 'virQEMUCapsFlags grouping marker',
- 'QEMU_CAPS_LAST /* this must')
+(header_lines, start, end) = load_file(args.prefix +
'src/qemu/qemu_capabilities.h',
+ 'virQEMUCapsFlags grouping marker',
+ 'QEMU_CAPS_LAST /* this must')
+capsflags = load_caps_flags(header_lines[start:end])
if not regroup_caps(args.check,
args.prefix + 'src/qemu/qemu_capabilities.c',
--
2.45.2