From nobody Thu Oct 31 00:25:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 17224321553111003.1223151571671; Wed, 31 Jul 2024 06:22:35 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1410113F4; Wed, 31 Jul 2024 09:22:34 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BD81613B0; Wed, 31 Jul 2024 09:21:47 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7B9C0143F; Wed, 31 Jul 2024 09:21:43 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 09F1713E5 for ; Wed, 31 Jul 2024 09:21:37 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-211-dX4-b31LPEuniH-EXgwcZQ-1; Wed, 31 Jul 2024 09:21:36 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 46D731955BF1 for ; Wed, 31 Jul 2024 13:21:35 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.70]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DCB191955E70 for ; Wed, 31 Jul 2024 13:21:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722432097; h=from:from: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; bh=uJTM7/Abrgvsn41eRRVMwlj1LIALlxHXYeIby+tp1bo=; b=SFzwV8V4YGfVbv3PWux1owGJKoSmR5nLqsRrQQ3vM+lvHQj0knapEEMQCgewV6sMKU7+cQ XOpGfZy7miSVN20ThNSiDePHEjMvZ5DI/8eJFyL25O+kdzYMurMVSvjL8FDb6hR/fXnLWk ViotFhfuZT+XofN3JF24Lv2sSNdY3Gc= X-MC-Unique: dX4-b31LPEuniH-EXgwcZQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH 2/6] scripts: group-qemu-caps: remove cryptic bool Date: Wed, 31 Jul 2024 15:20:48 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WZRYURVHZ2O6XVPGWGVEG4SAXPCHXPA2 X-Message-ID-Hash: WZRYURVHZ2O6XVPGWGVEG4SAXPCHXPA2 X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1722432157033116600 Content-Type: text/plain; charset="utf-8" Instead, iterate over (a part of) the array twice: * once to find where the caps start and end * once only over the lines with caps Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index ec10f24384..49b64c93fc 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -29,27 +29,29 @@ import sys =20 def load_caps_flags(filename, start_regex, end_regex): capsflags =3D [] - game_on =3D False lines =3D [] + start =3D 0 + end =3D 0 =20 with open(filename, "r") as fh: lines =3D fh.read().splitlines() =20 - for line in lines: - if game_on: - if re.search(r'''.*/\* [0-9]+ \*/.*''', line): - continue - if re.search(r'''^\s*$''', line): - continue - match =3D re.search(r'''[ ]+([A-Z0-9_]+)''', line) - - if match: - capsflags.append(match[1]) - + for idx, line in enumerate(lines): if re.search(start_regex, line): - game_on =3D True - elif game_on and re.search(end_regex, line): - game_on =3D False + start =3D idx + elif re.search(end_regex, line): + end =3D idx + break + + for line in lines[start:end]: + if re.search(r'''.*/\* [0-9]+ \*/.*''', line): + continue + if re.search(r'''^\s*$''', line): + continue + match =3D re.search(r'''[ ]+([A-Z0-9_]+)''', line) + + if match: + capsflags.append(match[1]) =20 return capsflags =20 --=20 2.45.2