From nobody Wed Oct 30 22:10:53 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 1722432136631963.7221503885445; Wed, 31 Jul 2024 06:22:16 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6C40D1434; Wed, 31 Jul 2024 09:22:15 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2DF3F13BB; Wed, 31 Jul 2024 09:21:41 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A18D3A58; Wed, 31 Jul 2024 09:21:36 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 3B2161392 for ; Wed, 31 Jul 2024 09:21:36 -0400 (EDT) Received: from mx-prod-mc-02.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-626-o4E7Dk2-MF-fx30Hsv3iYg-1; Wed, 31 Jul 2024 09:21:34 -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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 37E541956088 for ; Wed, 31 Jul 2024 13:21:33 +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 D12831955E80 for ; Wed, 31 Jul 2024 13:21:31 +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_H4,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=1722432095; 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=fzcH3BmiK4TuM0BedRhVewcG4+ZthGI6DysDZAkNgXA=; b=fNVBKtp+ywYUW8JtP+nsTE1A8RevXuOou7uE/2wSRmPcXYAxRFeGaQkFAUarM8+w+aSec0 TRbIFz92kn9pkGXwhXCYo4ejs2t4QjvshH5C9TOkTM97LaJdNYQEXN5tEg+9XbkkCo0v3v aupFim903DlRbY/XE/+RG7G/gptLJkE= X-MC-Unique: o4E7Dk2-MF-fx30Hsv3iYg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH 1/6] scripts: group-qemu-caps: use read Date: Wed, 31 Jul 2024 15:20:47 +0200 Message-ID: <0abe8450fc3bc7123fb28a74bceda9bb956bbcc7.1722432052.git.jtomko@redhat.com> 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: MF7QS356KNOK6YKYI6ZW5GACDW3MXVVV X-Message-ID-Hash: MF7QS356KNOK6YKYI6ZW5GACDW3MXVVV 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: 1722432136994116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index 8a899a76c2..ec10f24384 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -30,24 +30,26 @@ import sys def load_caps_flags(filename, start_regex, end_regex): capsflags =3D [] game_on =3D False + lines =3D [] =20 with open(filename, "r") as fh: - for line in fh: - line =3D line.rstrip("\n") - 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]) - - if re.search(start_regex, line): - game_on =3D True - elif game_on and re.search(end_regex, line): - game_on =3D False + lines =3D fh.read().splitlines() + + 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]) + + if re.search(start_regex, line): + game_on =3D True + elif game_on and re.search(end_regex, line): + game_on =3D False =20 return capsflags =20 --=20 2.45.2 From nobody Wed Oct 30 22:10:53 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 From nobody Wed Oct 30 22:10:53 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 1722432173429353.22715690508767; Wed, 31 Jul 2024 06:22:53 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6B8D0144A; Wed, 31 Jul 2024 09:22:52 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 718EF1408; Wed, 31 Jul 2024 09:21:54 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1A945145A; Wed, 31 Jul 2024 09:21:50 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 5FD7F13BA for ; Wed, 31 Jul 2024 09:21:40 -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-172-3-duPlzIOD-yApFkX_EV4A-1; Wed, 31 Jul 2024 09:21:38 -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 3267A1955F3B for ; Wed, 31 Jul 2024 13:21:37 +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 E8C021955E8C for ; Wed, 31 Jul 2024 13:21:35 +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_H4,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=1722432100; 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=203DPc0dIH+o6jFzvrcNc1WLVDvIg53iPd1nbN63+3Q=; b=SnawKVNvwriG7j6uevrMfbCqwIuw3CFde/HN812k8zcNk3BZv2ReuoqfI5/+VG/aC7mTvS InL4d5eVf2zH1PsfAyDyNwjcSYTPu2eKZP569wIJVi05zerhr4UAl4KEX6NypeElMo9C5j L5PZBmySj4AId/g7TnWRyhRNFFJGq7k= X-MC-Unique: 3-duPlzIOD-yApFkX_EV4A-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH 3/6] scripts: group-qemu-caps: remove unecessary regex Date: Wed, 31 Jul 2024 15:20:49 +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: SMA66LHEAPT44R6MHPTBL3XGBOEEDZ6C X-Message-ID-Hash: SMA66LHEAPT44R6MHPTBL3XGBOEEDZ6C 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: 1722432175089116600 Content-Type: text/plain; charset="utf-8" We're only looking at a simple string match. Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index 49b64c93fc..3581d1545a 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -27,7 +27,7 @@ import subprocess import sys =20 =20 -def load_caps_flags(filename, start_regex, end_regex): +def load_caps_flags(filename, start_str, end_str): capsflags =3D [] lines =3D [] start =3D 0 @@ -37,9 +37,9 @@ def load_caps_flags(filename, start_regex, end_regex): lines =3D fh.read().splitlines() =20 for idx, line in enumerate(lines): - if re.search(start_regex, line): + if start_str in line: start =3D idx - elif re.search(end_regex, line): + elif end_str in line: end =3D idx break =20 @@ -136,8 +136,8 @@ args =3D parser.parse_args() errs =3D False =20 capsflags =3D load_caps_flags(args.prefix + 'src/qemu/qemu_capabilities.h', - r'virQEMUCapsFlags grouping marker', - r'QEMU_CAPS_LAST \/\* this must') + 'virQEMUCapsFlags grouping marker', + 'QEMU_CAPS_LAST /* this must') =20 if not regroup_caps(args.check, args.prefix + 'src/qemu/qemu_capabilities.c', --=20 2.45.2 From nobody Wed Oct 30 22:10:53 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 1722432192321406.46832726526327; Wed, 31 Jul 2024 06:23:12 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 522BD1410; Wed, 31 Jul 2024 09:23:11 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6A88613EC; Wed, 31 Jul 2024 09:21:55 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B6CC413A2; Wed, 31 Jul 2024 09:21:51 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 5D45C143E for ; Wed, 31 Jul 2024 09:21:43 -0400 (EDT) Received: from mx-prod-mc-05.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-516-tdEfQ6a5Nl-9dzrBEOmhSw-1; Wed, 31 Jul 2024 09:21:40 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 499B21955F43 for ; Wed, 31 Jul 2024 13:21:39 +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 002881955E80 for ; Wed, 31 Jul 2024 13:21:37 +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_H4,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=1722432102; 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=zo5Icjf1BUJotfDcWdf+lOoFQJgbj5mPhPLvb9Sh1lQ=; b=GP4nMMreeP/QpRlkms0u/CWCxyObcayvVsTj6ujONU4DpDGIMMdJFq6Nriq1H82SzFk0De neK2Dm4RroIqfsDCR4z4V82I6wYUBi8cD+fpoT7w7kqdDyDAgjmZJ9EYxNY2YCBWInPRf7 G9kzNH41BLQuhsc7e4ctjOEtIeJu6S0= X-MC-Unique: tdEfQ6a5Nl-9dzrBEOmhSw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH 4/6] scripts: group-qemu-caps: separate file loading Date: Wed, 31 Jul 2024 15:20:50 +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: ER33KVFKUZPANPETWI3OOW2CBYUHPZHD X-Message-ID-Hash: ER33KVFKUZPANPETWI3OOW2CBYUHPZHD 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: 1722432193231116600 Content-Type: text/plain; charset="utf-8" Separate file loading from its parsing. Signed-off-by: J=C3=A1n Tomko --- 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 =20 =20 -def load_caps_flags(filename, start_str, end_str): - capsflags =3D [] +def load_file(filename, start_str, end_str): lines =3D [] start =3D 0 end =3D 0 @@ -43,7 +42,13 @@ def load_caps_flags(filename, start_str, end_str): end =3D idx break =20 - for line in lines[start:end]: + return (lines, start, end) + + +def load_caps_flags(lines): + capsflags =3D [] + + for line in lines: if re.search(r'''.*/\* [0-9]+ \*/.*''', line): continue if re.search(r'''^\s*$''', line): @@ -135,9 +140,10 @@ args =3D parser.parse_args() =20 errs =3D False =20 -capsflags =3D load_caps_flags(args.prefix + 'src/qemu/qemu_capabilities.h', - 'virQEMUCapsFlags grouping marker', - 'QEMU_CAPS_LAST /* this must') +(header_lines, start, end) =3D load_file(args.prefix + 'src/qemu/qemu_capa= bilities.h', + 'virQEMUCapsFlags grouping marker', + 'QEMU_CAPS_LAST /* this must') +capsflags =3D load_caps_flags(header_lines[start:end]) =20 if not regroup_caps(args.check, args.prefix + 'src/qemu/qemu_capabilities.c', --=20 2.45.2 From nobody Wed Oct 30 22:10:53 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 1722432213782990.8629201919554; Wed, 31 Jul 2024 06:23:33 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 893EE13EC; Wed, 31 Jul 2024 09:23:32 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 87D241421; Wed, 31 Jul 2024 09:21:58 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5682D13E9; Wed, 31 Jul 2024 09:21:53 -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 1024B141F for ; Wed, 31 Jul 2024 09:21:45 -0400 (EDT) Received: from mx-prod-mc-04.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-619-9E6LOeDxNsuQ7rEQ9bEJyg-1; Wed, 31 Jul 2024 09:21:42 -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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 49C301955D56 for ; Wed, 31 Jul 2024 13:21:41 +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 0BBF61955E80 for ; Wed, 31 Jul 2024 13:21:39 +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=1722432104; 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=bHsjWcYBzeH3XiY1dG1WzzzZguOeSPVHt7r2EsNThJw=; b=dy4pxTQ14IBIaEZiyYKN1G4ZtC32/xEbDpuezYEBure+hBMoIqmMrZwUc8pGgzpTQkNNTh v+U76DakrivI1DnsipqTE2JSZZn06xYgvOTtotS1s3NTeVXLduD/ePRcXms41bzSv/WItL 11aS3H4RWZdHMKj32DsitwE5N1QcrAs= X-MC-Unique: 9E6LOeDxNsuQ7rEQ9bEJyg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH 5/6] scripts: group-qemu-caps: regroup_caps: operate on split lines Date: Wed, 31 Jul 2024 15:20:51 +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: PO24ATLL2DUSUHUKQMXKDEK2W2IO3ZCG X-Message-ID-Hash: PO24ATLL2DUSUHUKQMXKDEK2W2IO3ZCG 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: 1722432215402116600 Content-Type: text/plain; charset="utf-8" This removes some newline handling at the cost of adding it elsewhere. Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index a43cd1de45..34823931df 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -67,14 +67,12 @@ def regroup_caps(check, filename, start_regex, end_rege= x, =20 original =3D [] with open(filename, "r") as fh: - for line in fh: - original.append(line) + original =3D fh.read().splitlines() =20 fixed =3D [] game_on =3D False counter =3D 0 for line in original: - line =3D line.rstrip("\n") if game_on: if re.search(r'''.*/\* [0-9]+ \*/.*''', line): continue @@ -82,8 +80,8 @@ def regroup_caps(check, filename, start_regex, end_regex, continue if counter % step =3D=3D 0: if counter !=3D 0: - fixed.append("\n") - fixed.append("%s/* %d */\n" % (counter_prefix, counter)) + fixed.append("") + fixed.append("%s/* %d */" % (counter_prefix, counter)) =20 if not (line.find("/*") !=3D -1 and line.find("*/") =3D=3D -1): # count two-line comments as one line @@ -98,7 +96,7 @@ def regroup_caps(check, filename, start_regex, end_regex, fixed =3D fixed[:-1] # \n =20 if trailing_newline: - fixed.append("\n") + fixed.append("") =20 game_on =3D False =20 @@ -108,11 +106,11 @@ def regroup_caps(check, filename, start_regex, end_re= gex, if flagname: line =3D flagname[0] + " /* %s */" % capsflags[counter - 1] =20 - fixed.append(line + "\n") + fixed.append(line) =20 if check: - orig =3D "".join(original) - new =3D "".join(fixed) + orig =3D "\n".join(original) + "\n" + new =3D "\n".join(fixed) + "\n" if new !=3D orig: diff =3D subprocess.Popen(["diff", "-u", filename, "-"], stdin=3Dsubprocess.PIPE) @@ -126,7 +124,7 @@ def regroup_caps(check, filename, start_regex, end_rege= x, else: with open(filename, "w") as fh: for line in fixed: - print(line, file=3Dfh, end=3D'') + print(line, file=3Dfh) =20 return True =20 --=20 2.45.2 From nobody Wed Oct 30 22:10:53 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 1722432238390147.51333497523626; Wed, 31 Jul 2024 06:23:58 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4F85713E5; Wed, 31 Jul 2024 09:23:57 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 98E4D13B8; Wed, 31 Jul 2024 09:22:01 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A656713F0; Wed, 31 Jul 2024 09:21:54 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 E4437140E for ; Wed, 31 Jul 2024 09:21:45 -0400 (EDT) Received: from mx-prod-mc-05.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-248-Dw9vYFGzNSyNh3Kn41DT5w-1; Wed, 31 Jul 2024 09:21:44 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 731D61956046 for ; Wed, 31 Jul 2024 13:21:43 +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 17F3A1955E8C for ; Wed, 31 Jul 2024 13:21:41 +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_H4,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=1722432105; 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=p6jiNRTnxIufoJ/aKVo6Y/nJvqm/tirLyuekJvKsVxY=; b=ZvxgWEjuS0O8XH/ifu5BZKycVaSZ2oihSbKW698B3h1DGpTSdjH92Qn14FsXectY0dVZ/C BCopkek+SqY9QFn6t83d2UU0nr7Dy+vUklf5N9d1gH5QuOga57aWkfzcofrzKgbC8p6xCl 3/coIBD9H3Lwsbz/wjLT0tKhUt17fv4= X-MC-Unique: Dw9vYFGzNSyNh3Kn41DT5w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: devel@lists.libvirt.org Subject: [libvirt PATCH 6/6] scripts: group-qemu-caps: separate file operations from the check Date: Wed, 31 Jul 2024 15:20:52 +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: LKH7QEQA3FY44CVM75BSFCIWC6CZSTE7 X-Message-ID-Hash: LKH7QEQA3FY44CVM75BSFCIWC6CZSTE7 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: 1722432239402116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 50 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index 34823931df..e4161f5bb5 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -61,14 +61,9 @@ def load_caps_flags(lines): return capsflags =20 =20 -def regroup_caps(check, filename, start_regex, end_regex, +def regroup_caps(original, start_regex, end_regex, trailing_newline, counter_prefix, capsflags): step =3D 5 - - original =3D [] - with open(filename, "r") as fh: - original =3D fh.read().splitlines() - fixed =3D [] game_on =3D False counter =3D 0 @@ -107,7 +102,10 @@ def regroup_caps(check, filename, start_regex, end_reg= ex, line =3D flagname[0] + " /* %s */" % capsflags[counter - 1] =20 fixed.append(line) + return fixed =20 + +def check(check, filename, original, fixed): if check: orig =3D "\n".join(original) + "\n" new =3D "\n".join(fixed) + "\n" @@ -143,22 +141,32 @@ errs =3D False 'QEMU_CAPS_LAST /* this must') capsflags =3D load_caps_flags(header_lines[start:end]) =20 -if not regroup_caps(args.check, - args.prefix + 'src/qemu/qemu_capabilities.c', - r'virQEMUCaps grouping marker', - r'\);', - 0, - " ", - capsflags): +(source_lines, source_start, source_end) =3D load_file(args.prefix + 'src/= qemu/qemu_capabilities.c', + r'virQEMUCaps groupin= g marker', + r'\);') +fixed_source =3D regroup_caps(source_lines, + r'virQEMUCaps grouping marker', + r'\);', + 0, + " ", + capsflags) + +fixed_header =3D regroup_caps(header_lines, + r'virQEMUCapsFlags grouping marker', + r'QEMU_CAPS_LAST \/\* this must', + 1, + " ", + None) + +if not check(args.check, + args.prefix + 'src/qemu/qemu_capabilities.c', + source_lines, + fixed_source): errs =3D True - -if not regroup_caps(args.check, - args.prefix + 'src/qemu/qemu_capabilities.h', - r'virQEMUCapsFlags grouping marker', - r'QEMU_CAPS_LAST \/\* this must', - 1, - " ", - None): +if not check(args.check, + args.prefix + 'src/qemu/qemu_capabilities.h', + header_lines, + fixed_header): errs =3D True =20 if errs: --=20 2.45.2