From nobody Mon Feb 9 09:08:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629815162; cv=none; d=zohomail.com; s=zohoarc; b=KrRiwVcL1DAv0aU7LmCPbKI6BjLmL/yMVrpBgWOPkOS18zNRN2cOogq+CCanvO+9/FkIjLzO6QnON6ug3Bb8E2ZhBeDFGm27GFDTVUAX2ovlzI38AtnkdFzJH/tymZYBdARDw3J//fQyx8L5Khft3imziWkwDszB1tUIxMzMQmk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815162; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oU5yQr6GoeICIwiBvdQ7yjJgSSVfjhTqfofIhj0dPCE=; b=dHj4aNFVNOv+OyTu2xO1qNb7mQwc/dk9d235SQIFRSvHP4DfVSIbNmBsW1Z+XEItqOYuMUKhjpMJTx4ljrOpMBe3pLe6gH4HJi5fNoV6Lk+93aMAdOsZQH91mTGE/pmSkXA65xI+9L5RamTtSEg4ngByWc/ZGQTrU4f4NCmSKOA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1629815162071645.9855851703435; Tue, 24 Aug 2021 07:26:02 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-GBhzZkdyN0mYxlMDef0-1w-1; Tue, 24 Aug 2021 10:25:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6E2C801A92; Tue, 24 Aug 2021 14:25:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4ED960C0F; Tue, 24 Aug 2021 14:25:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4DBE4181A2A6; Tue, 24 Aug 2021 14:25:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17OEPp04003317 for ; Tue, 24 Aug 2021 10:25:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id E595A6A8FA; Tue, 24 Aug 2021 14:25:51 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E3286A8F7 for ; Tue, 24 Aug 2021 14:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815161; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=oU5yQr6GoeICIwiBvdQ7yjJgSSVfjhTqfofIhj0dPCE=; b=LuE/f+VpALr/QtqksJAW3G47XtDOCmsWuhnFpBspVAanUvdvYCj6b4c1La3uB/vsBEt47f QFwYpca+shmtX7WI2pBrGympW1rW7i2c1uI4mVKhhskyeNOqGUaGvkJaZ/ats96iiQ8rvt H18AWjsivICW8ZGhfguZXj0PhoKdv0w= X-MC-Unique: GBhzZkdyN0mYxlMDef0-1w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 07/11] scripts: group-qemu-caps: introduce find_markers Date: Tue, 24 Aug 2021 16:25:10 +0200 Message-Id: <1686229b91855284374f2c2505717eb7e1d1b129.1629815074.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629815163360100001 Get indexes of the two marker strings. Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index 2eaaf06bb4..29ab268c4c 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -35,19 +35,24 @@ def load_file(filename): return lines =20 =20 -def load_caps_flags(lines, start_regex, end_regex): - capsflags =3D [] +def find_markers(lines, start_marker, end_marker): start =3D 0 end =3D 0 =20 for idx, line in enumerate(lines): - if re.search(start_regex, line): + if start_marker in line: start =3D idx - elif re.search(end_regex, line): + elif end_marker in line: end =3D idx break =20 - for line in lines[start:end]: + return (start, end) + + +def load_caps_flags(lines): + capsflags =3D [] + + for line in lines: match =3D re.search(r'''[ ]+([A-Z0-9_]+),''', line) =20 if match: @@ -137,9 +142,10 @@ header_path =3D args.prefix + 'src/qemu/qemu_capabilit= ies.h' source_path =3D args.prefix + 'src/qemu/qemu_capabilities.c' =20 header_lines =3D load_file(header_path) -capsflags =3D load_caps_flags(header_lines, - r'virQEMUCapsFlags grouping marker', - r'QEMU_CAPS_LAST \/\* this must') +(start, end) =3D find_markers(header_lines, + 'virQEMUCapsFlags grouping marker', + 'QEMU_CAPS_LAST /* this must') +capsflags =3D load_caps_flags(header_lines[start:end]) =20 if not regroup_caps(args.check, source_path, --=20 2.31.1