From nobody Sun May 5 13:19:27 2024 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=1629815137; cv=none; d=zohomail.com; s=zohoarc; b=kjE5fL2ybegKGtBsrixgeyjB4Wxjpw5J0sKYhB87LDNjDoR0JCxdbNP+tTB3PZvY1jaUzLeSH0M2DuzLLgrEdkrzhh0+TT/EmZqsBnHnSWZrSGDLQt+FTqPYbdv0Rugl2vD34qRwPms51CXZ590h/+Zd6UnwcW09fqWJ3BPvH3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815137; 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=psNe1QV7k97iiSqHiKGnOYU5uAQK7BZ24HOggQwg6fk=; b=M90uUMS1SxwU0P/DVpHKNt/xx49aQPVT12Xg9BfMLacCxmRNkqXnc9imnDOapbt0iPECwUzUHG59G1YT33vezw9tKFnfbZijfJ41BLNEv4Lv6bPHNIZ7sDgn3RnZgqqhQnoxpHfCQA3AyuaIxGrn4j+0nT1Tuxxu871Qv5L/VOA= 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 1629815137628146.43292615523296; Tue, 24 Aug 2021 07:25:37 -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-106-53sJnircMPO0jGTemSeMyQ-1; Tue, 24 Aug 2021 10:25:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 841E91008062; Tue, 24 Aug 2021 14:25:26 +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 606995D9C6; Tue, 24 Aug 2021 14:25:26 +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 27328181A100; Tue, 24 Aug 2021 14:25:26 +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 17OEPLnh002848 for ; Tue, 24 Aug 2021 10:25:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8B0AF18649; Tue, 24 Aug 2021 14:25:21 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 140525D6CF for ; Tue, 24 Aug 2021 14:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815136; 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=psNe1QV7k97iiSqHiKGnOYU5uAQK7BZ24HOggQwg6fk=; b=QbhukAyHlJzgEbvZBzd9ZNyFXRBlIgMCwHbW/vYdVW92PWf925EQnzDlvpTYZuuBQF6VeC kaK0p8krFfYXOQZv8HNrBs+ZoMkTBeH3NGqA1pMuhJ5+Mc+qBvO91mUoLUFGKJEL/opJjn gv9x+pfkePqcXZIoI+VnBGnT3WVnkaU= X-MC-Unique: 53sJnircMPO0jGTemSeMyQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 01/11] scripts: group-qemu-caps: read file separately in load_caps_flags Date: Tue, 24 Aug 2021 16:25:04 +0200 Message-Id: <463328d94fbc1648def54a108d498303b7ec2b5a.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.14 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: 1629815139314100001 Split the file by lines and store it in a list. Switch the rest of the function to operate on this list, to prepare for splitting out the fire reading logic. Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 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) + lines =3D fh.read().splitlines() =20 - if match: - capsflags.append(match[1]) + 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) =20 - if re.search(start_regex, line): - game_on =3D True - elif game_on and re.search(end_regex, line): - game_on =3D False + 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.31.1 From nobody Sun May 5 13:19:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1629815164; cv=none; d=zohomail.com; s=zohoarc; b=nwvpAiWUXV35eVqzgM86uXZm6CeSyzU0O89Pfqxo1yTuLNzOz5uomBYpcfC5L/bxuko3Uz4vV5MDySYwvTGszCxXDDZNXf2WYV0N5D+4D81wXa/CFXmXBMr1q9zjCmHJW8KOJJmAcSAndBHP2vpPhvs6us1K7Pds2V42nqp8yrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815164; 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=ZUXZLrDtWGQ4+c621mq5aOa2W4ARm371dGSynE9x3Aw=; b=bPQBQ+rdiCa8b4KzMnu19SqkEMoJ6Np/gqBXsPRts90GF6wPnyhGjVWkvbciNFJF61BjslofDiIcRuD/r0ObZX5GQdi1RfOXlhhuTHvYSsbIfgQsrimVQ9aE/Rxr0irCXUzF6feGbRObbL0ar2s2g6EzoiJDtFaX9U+K7P5jBWY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629815164380702.1611837006598; Tue, 24 Aug 2021 07:26:04 -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-312-D1LJDt1tMNimTCtLQJPEcg-1; Tue, 24 Aug 2021 10:25:36 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 81082CC624; Tue, 24 Aug 2021 14:25:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DE525D6CF; Tue, 24 Aug 2021 14:25:29 +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 E7CDD4A7CD; Tue, 24 Aug 2021 14:25:28 +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 17OEPMQm002859 for ; Tue, 24 Aug 2021 10:25:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A18B18649; Tue, 24 Aug 2021 14:25:22 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7F445D6CF for ; Tue, 24 Aug 2021 14:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815163; 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=ZUXZLrDtWGQ4+c621mq5aOa2W4ARm371dGSynE9x3Aw=; b=FmieSynpVKoeMNMNJj6wDkjVWHCqQeIJKPhFkCcWhtn8AcfONhtiP0UtyZymka6oBwcNQ9 tOh3rYaUjverm7WSxp7OMlsakmA1Ee3ili2kw+lRJI/iQgaVMrppJ3W4+iO1tDbjdcwFsj pvXicQnvnc+JujfwDUTcv2Az64y1LnM= X-MC-Unique: D1LJDt1tMNimTCtLQJPEcg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 02/11] scripts: group-qemu-caps: store paths in helper variables Date: Tue, 24 Aug 2021 16:25:05 +0200 Message-Id: <75b85441c99820af41133c6c30b75fed75722bba.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.15 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: 1629815165450100003 Avoid repetition and specifying the path to the header file twice. Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index ec10f24384..bd22dd992a 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -133,12 +133,15 @@ args =3D parser.parse_args() =20 errs =3D False =20 -capsflags =3D load_caps_flags(args.prefix + 'src/qemu/qemu_capabilities.h', +header_path =3D args.prefix + 'src/qemu/qemu_capabilities.h' +source_path =3D args.prefix + 'src/qemu/qemu_capabilities.c' + +capsflags =3D load_caps_flags(header_path, r'virQEMUCapsFlags grouping marker', r'QEMU_CAPS_LAST \/\* this must') =20 if not regroup_caps(args.check, - args.prefix + 'src/qemu/qemu_capabilities.c', + source_path, r'virQEMUCaps grouping marker', r'\);', 0, @@ -147,7 +150,7 @@ if not regroup_caps(args.check, errs =3D True =20 if not regroup_caps(args.check, - args.prefix + 'src/qemu/qemu_capabilities.h', + header_path, r'virQEMUCapsFlags grouping marker', r'QEMU_CAPS_LAST \/\* this must', 1, --=20 2.31.1 From nobody Sun May 5 13:19:27 2024 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=1629815134; cv=none; d=zohomail.com; s=zohoarc; b=bd/0c7xwSOoB6b6mvCVkLWvq6TuD0U37qChsuQzov/9uqP9TkulhfdW6n8KtlFSOtKXZbt2llT7bjpjzTFngfnpfc7BpzHLtP7/CnVU4TzCVIaejKruDEYOSLzsBgsRcA+9EjhP2khr2k4XkgCdHQcfGHzwL23onaGPRunxp1dE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815134; 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=3qI/l63qZCkQultz14eY9J3rcDen/ubn9Owq3poNaG0=; b=XKySOOvE7M2mKZzEN5JO3+Yc/Br4o3J9CagvFube/2StzIJ+GmC9Ty4DKvHtLjX6LmoaNnrsqa9obkbk/6OlLaZctZWwbcZE4sl18I8v2b+bGEzRwEfWRTN46nc+J35HL3EiQanABObNGVXaPRF8q/a1A5wYrUgtmEnXijb5fFo= 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 1629815134737867.8423954414222; Tue, 24 Aug 2021 07:25:34 -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-556-05oOj-WlM5ec4KEViTlGLg-1; Tue, 24 Aug 2021 10:25:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F9721008073; Tue, 24 Aug 2021 14:25:25 +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 6E7925D9C6; Tue, 24 Aug 2021 14:25:25 +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 0EAD4181A0F9; Tue, 24 Aug 2021 14:25:25 +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 17OEPN2x002874 for ; Tue, 24 Aug 2021 10:25:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 29C741ABDF; Tue, 24 Aug 2021 14:25:23 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6E175D6CF for ; Tue, 24 Aug 2021 14:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815133; 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=3qI/l63qZCkQultz14eY9J3rcDen/ubn9Owq3poNaG0=; b=R/MIo3Ydqowu1AUgDxpSwwsECCI72bDW50kneQhQX/DqhdhwuvU/sc6VMz9dmLR5YefuCr kqcpjXXm0WK1y8pTHq1VOc1t4IYhZETEDY21i8vfy9K4B2KnBSMws/CtmAiGa9XERkyylr o0rqEecmyXJ3bWoAk8L1K1EeJ3Ovr/Q= X-MC-Unique: 05oOj-WlM5ec4KEViTlGLg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 03/11] scripts: group-qemu-caps: remove cryptic bool from load_caps_flags Date: Tue, 24 Aug 2021 16:25:06 +0200 Message-Id: <7f60ea005b3affe2ade06e78219dd0c258ce4aec.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.14 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: 1629815136908100001 Enumerate over lines early to find out the position of the starting and ending markers. Then run the actual function on the lines between those markers. 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 bd22dd992a..e56c306d10 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.31.1 From nobody Sun May 5 13:19:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1629815137; cv=none; d=zohomail.com; s=zohoarc; b=SkpzhNK496nRoOENk6i2mjLPI27Lo2VFebPoZB9bAaDE6dtQ2LrEyTG2eUgwVC46kHuOEzWAoPOMI4UH9FDjqfuex2v85+krM3JlFEf8TmgFpIF8vc5kYU+94+4hAMDkxvRuV03jMK9pLkYjIX7Fbmm06pNiO7iZFbKYYLeXmJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815137; 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=S9qH5Nkcb+insHw4p2faPwqlBfKS1x7yYq6j7ar5J8w=; b=IJxXfyCw0GI7PAegTdse8fC5A4JULg7U0+gETvaEoFbiNq6YKwDt9CFe+igynPXx1MiXvWufF0wUeEaKtKe2xmw0cKGgYy1nIFYo2Wb7eGjlpyFYRjDFC5CgNYAB1eewZ+m058/klSm8lOPfhjOnA4RKcuLnz+NY2COls7qAQOo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629815137972981.0955098116626; Tue, 24 Aug 2021 07:25:37 -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-281-AxGTBpv5Muac9X21syt0ug-1; Tue, 24 Aug 2021 10:25:35 -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 834B418C89DA; Tue, 24 Aug 2021 14:25:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63FCC60C0F; Tue, 24 Aug 2021 14:25:28 +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 313D54A7CA; Tue, 24 Aug 2021 14:25:28 +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 17OEPQDe002909 for ; Tue, 24 Aug 2021 10:25:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id E18371ABDF; Tue, 24 Aug 2021 14:25:26 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A4885D6CF for ; Tue, 24 Aug 2021 14:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815137; 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=S9qH5Nkcb+insHw4p2faPwqlBfKS1x7yYq6j7ar5J8w=; b=UmIjcGJE+zPlvCaxGo11RSmyaibQqsb0FUkP6H0JqOXeePIGfqdrsGHXlwH27pHMzoo6em 18k3NJ7BDMRXIxUQMbrOW+seMdFJxLHmXDVtdDmejPClY9/GQWiN7H98cYY7jDEDZKDRqN 1OTIn7AaPaP/w0fvw91WD16oXKM1opY= X-MC-Unique: AxGTBpv5Muac9X21syt0ug-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 04/11] scripts: group-qemu-caps: remove unnecessary regexes Date: Tue, 24 Aug 2021 16:25:07 +0200 Message-Id: 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: 1629815139402100002 regroup_caps uses these to filter out lines that should not increase the counter. Here, we only care about the capability constants, so we can let the final matching regex take care of the matching. Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index e56c306d10..ee33f1cf16 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -44,11 +44,7 @@ def load_caps_flags(filename, start_regex, end_regex): break =20 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) + match =3D re.search(r'''[ ]+([A-Z0-9_]+),''', line) =20 if match: capsflags.append(match[1]) --=20 2.31.1 From nobody Sun May 5 13:19:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1629815166; cv=none; d=zohomail.com; s=zohoarc; b=LWnFnrZquT2hal7SEmO1YXODDU+KdYR558/lLWv7AbPRSFsgougV61S3a1X0sEPOVqe81cLFtV0K6SmE0XrLH+Nk10fufqfrL55kN5/s60WxsXP92ehANxZS6M1GQ+Y+nycOH5wi7siUCQu3E44BKVRGkBIOu8qOr3hCTivyU/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815166; 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=AcvS0GlZP3aXQhaMox/S+GEsrj4HhDUwofuQglGA5U0=; b=SctrjgxqHLcE8P09J0W+e2O5sGOE5UrmYk1pTY14iJVP36Q+Hzb/4IFzcLBr8F4kR69Ewqj89rZUzxS84XlA9wc+w0mfReZjY44WoxHR41TwIgPNOd2VutsKoyGzbvHC4EDfcUOXXNRTE/izUa8C0eTT4bOdu5sPNRSbCtQjSDA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 162981516688988.20507741344466; Tue, 24 Aug 2021 07:26:06 -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-41-W4_LaGUAPAqp84FD0g3Jcg-1; Tue, 24 Aug 2021 10:25:38 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D86C838E65; Tue, 24 Aug 2021 14:25:32 +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 56E4110074E1; Tue, 24 Aug 2021 14:25:32 +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 1F495181A1D3; Tue, 24 Aug 2021 14:25:32 +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 17OEPUJo002978 for ; Tue, 24 Aug 2021 10:25:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8BA8E6A8FE; Tue, 24 Aug 2021 14:25:30 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14A3A5D6CF for ; Tue, 24 Aug 2021 14:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815165; 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=AcvS0GlZP3aXQhaMox/S+GEsrj4HhDUwofuQglGA5U0=; b=ABRrWtbHe+tSbx6/HMz9vU55z+gBkDsQIFlfnizyZ+wmiS/jLgNCWlzeC/h3ixNXa4WI1M U35PxXjim7ndpCoA9+21CNiUunw5M5j7lgWHmnNztWCpSvnKFV9GaqLZ49B7F8LY8eIldM QNvdO1Ygi4yq31fpdBMgpih+8BRy/3U= X-MC-Unique: W4_LaGUAPAqp84FD0g3Jcg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 05/11] scripts: group-qemu-caps: split lines in regroup_caps Date: Tue, 24 Aug 2021 16:25:08 +0200 Message-Id: <2f313f3ddc8c44ce23cb5123a39cac0e331a0a3e.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.84 on 10.5.11.22 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: 1629815167725100001 For consistency, operate on split lines and re-add the newlines later. 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 ee33f1cf16..ca5f9b7247 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -58,14 +58,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 @@ -73,8 +71,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 @@ -89,7 +87,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 @@ -99,11 +97,11 @@ def regroup_caps(check, filename, start_regex, end_rege= x, 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) @@ -117,7 +115,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.31.1 From nobody Sun May 5 13:19:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1629815146; cv=none; d=zohomail.com; s=zohoarc; b=WaZEOZaV8BjwE2UO2locSWJurYEq0dzpWLdAbLzvU3ZRq+eplKutL4GG4Ui0GHhQrz49WbJgEfUjy5DYrsb/aINBjV6zSovxwX4zF5VCV0Sf1WOEueIze4/2e8Ky1cERhp3U435rEu7TVBg7FtSpSPbFmZj0uflTlxdUehTkq4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815146; 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=lSPb6+5lp0uPERcewN/0rjv5wGAvOUPNkvy8pDlIUGo=; b=ZthEmV44idV52zr/BNq4RwiWdF7Tyr0/mbHjUPY/ELad0JomXLpqr/3G72J9CbmVp+Q7V3XYZzs65TS7Kk8XaKgZzIisfZB9KjK7XHXYvl3vR/vKMab6DRYwMeXUZU6gMrVraa82T4YeGLCFeNLy3UzdPSh5ugBMxKi1odklw8k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629815146361181.6290028687772; Tue, 24 Aug 2021 07:25:46 -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-165-nmYnRuMuOHehJPBwI2cyAA-1; Tue, 24 Aug 2021 10:25:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C9767101C8AC; Tue, 24 Aug 2021 14:25:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A536A10013D6; Tue, 24 Aug 2021 14:25:36 +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 728B14A706; Tue, 24 Aug 2021 14:25:36 +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 17OEPZxN002989 for ; Tue, 24 Aug 2021 10:25:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8436D6A8FE; Tue, 24 Aug 2021 14:25:35 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 092DF5D6CF for ; Tue, 24 Aug 2021 14:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815145; 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=lSPb6+5lp0uPERcewN/0rjv5wGAvOUPNkvy8pDlIUGo=; b=SV8k+1KSAZg0gzOwfltGYts6t3114+iqneC9/Dja/Ht0qlJPT3VXV/K7ByEfEbFYTLNPNs 5P2eIF5VewyY0lx2HNrEXu52hMBWc8mguuLwZ/ofo0MyueeDcYRNBHDO0Wi7v+SOBR/ggX aEQBwPMsylGYPCM9i+XO9K2jm0Dee9Y= X-MC-Unique: nmYnRuMuOHehJPBwI2cyAA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 06/11] scripts: group-qemu-caps: introduce load_file Date: Tue, 24 Aug 2021 16:25:09 +0200 Message-Id: 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.84 on 10.5.11.22 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: 1629815147255100001 Turn a file into a list of split lines. Signed-off-by: J=C3=A1n Tomko --- 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 =20 =20 -def load_caps_flags(filename, start_regex, end_regex): - capsflags =3D [] +def load_file(filename): lines =3D [] + with open(filename, "r") as fh: + lines =3D fh.read().splitlines() + + return lines + + +def load_caps_flags(lines, start_regex, end_regex): + capsflags =3D [] start =3D 0 end =3D 0 =20 - with open(filename, "r") as fh: - lines =3D fh.read().splitlines() - for idx, line in enumerate(lines): if re.search(start_regex, line): start =3D idx @@ -132,7 +136,8 @@ errs =3D False header_path =3D args.prefix + 'src/qemu/qemu_capabilities.h' source_path =3D args.prefix + 'src/qemu/qemu_capabilities.c' =20 -capsflags =3D load_caps_flags(header_path, +header_lines =3D load_file(header_path) +capsflags =3D load_caps_flags(header_lines, r'virQEMUCapsFlags grouping marker', r'QEMU_CAPS_LAST \/\* this must') =20 --=20 2.31.1 From nobody Sun May 5 13:19:27 2024 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 From nobody Sun May 5 13:19:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1629815178; cv=none; d=zohomail.com; s=zohoarc; b=Tjbeekh/xN0DwQOfkKIX9KgwbhbeQl50pzPQifi7uKUgZlG145GHMvaKFrKaoxHd9T6HWMHglnbr5uduQ3cyB9+l5mdYnvCmzaH1JWaABKrwrTIH9d8FaqpQ6SR3Zln+ZOG7EUJyBj2OiWGvqRFFVL4cmgXUof/9X/tYoF5JsC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815178; 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=YGGdlIJRvMRVdToauP8zM2jSzjRzaAdD+Nd1uoxLAZI=; b=OHpTj3a6K0S4DLwdy2FXBRu1LUQzxKTrPA5zI1DFJyb+rcUUE7z56yXXbSXSTv0t9FwQVbjhIOA3kZfiVPeaC/E6Z0D31ozaDc0WBCnrbfIXdT4E47gpl3zdRR7UK3N5ATnUsxOJTRxRUlJmce6riM5UH4Ndnx5iydF5o0xgtSI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629815178396401.6142197108967; Tue, 24 Aug 2021 07:26:18 -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-515-a7ZOEUWGNI2jkPNAveNnYA-1; Tue, 24 Aug 2021 10:26:04 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07E66101C8A5; Tue, 24 Aug 2021 14:25:59 +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 769301036D20; Tue, 24 Aug 2021 14:25:58 +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 3E3B9181A2A9; Tue, 24 Aug 2021 14:25:58 +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 17OEPvqf003406 for ; Tue, 24 Aug 2021 10:25:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 09FC569323; Tue, 24 Aug 2021 14:25:57 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 865865D6CF for ; Tue, 24 Aug 2021 14:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815177; 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=YGGdlIJRvMRVdToauP8zM2jSzjRzaAdD+Nd1uoxLAZI=; b=gnq7akr65IZFxGg3r2+ulnIHMrG5dJoVbQjDwDMmUBGyXsUu9mht8ruGtcuoum0BpJdYAT oxHAnfFV1hB+OjZHzudWTUkvlJ+taxBqwBMrsLpyD0yHcBSQA1qHm0X6XC77VPMWn3kY4p kccnSnD0NqYM04zuR0I8dxIVeDZecVU= X-MC-Unique: a7ZOEUWGNI2jkPNAveNnYA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 08/11] scripts: group-qemu-caps: introduce check_wrapping Date: Tue, 24 Aug 2021 16:25:11 +0200 Message-Id: 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.84 on 10.5.11.22 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: 1629815179584100002 Remove the logic that compares the expected and actual output. Also split out reading of the file - letting regroup_caps deal with just the lines for now. Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 51 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index 29ab268c4c..dce25099b8 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 @@ -108,6 +103,10 @@ def regroup_caps(check, filename, start_regex, end_reg= ex, =20 fixed.append(line) =20 + return fixed + + +def check_wrapping(filename, original, fixed, check): if check: orig =3D "\n".join(original) + "\n" new =3D "\n".join(fixed) + "\n" @@ -142,28 +141,36 @@ header_path =3D args.prefix + 'src/qemu/qemu_capabili= ties.h' source_path =3D args.prefix + 'src/qemu/qemu_capabilities.c' =20 header_lines =3D load_file(header_path) +source_lines =3D load_file(source_path) (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, - r'virQEMUCaps grouping marker', - r'\);', - 0, - " ", - capsflags): - errs =3D True +header_fixed =3D regroup_caps(header_lines, + r'virQEMUCapsFlags grouping marker', + r'QEMU_CAPS_LAST \/\* this must', + 1, + " ", + None) +source_fixed =3D regroup_caps(source_lines, + r'virQEMUCaps grouping marker', + r'\);', + 0, + " ", + capsflags) =20 -if not regroup_caps(args.check, - header_path, - r'virQEMUCapsFlags grouping marker', - r'QEMU_CAPS_LAST \/\* this must', - 1, - " ", - None): - errs =3D True +if not check_wrapping(header_path, + header_lines, + header_fixed, + args.check): + ret =3D False + +if not check_wrapping(source_path, + source_lines, + source_fixed, + args.check): + ret =3D False =20 if errs: sys.exit(1) --=20 2.31.1 From nobody Sun May 5 13:19:27 2024 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=1629815172; cv=none; d=zohomail.com; s=zohoarc; b=ivmDV9Lxi3dedlr5V4Z8IdawpdiU0nbjqyj3RhPpF+hn2yViAHEkdguq+ckugvIwacA5CMAPHzDZztFLdY3wlA/2tTEAfADxcmGwGuAkBBJvPIW303xuZl9AdqB+lOOKZiyER2fyM2WeF3ak2/R/B7EQL45KllIrwCyhlYLUTLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815172; 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=xGQr9cFpwb8xY80pKclzG9c9ORXp0ilOQxPnkiTGl/0=; b=RzBRq42KpIFMvAM4UDNX2XdUJigGZGUKrEZbUbKuAlet7m02jpgE+fA08ihyTrwQX5Wj6dEraW896j1p4N5wFa+yB/Qu8bbmIPrEOF4O4cby9cClpO+PKDZX48EkO7w2Aot1Ecki7yP2qIbdifT4sA2nxdkGDCIfGSEheOOL4iE= 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 1629815172108871.6089863193893; Tue, 24 Aug 2021 07:26:12 -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-160-y3717PwWMXCJuLnrAVnGAQ-1; Tue, 24 Aug 2021 10:26:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 06945CC62B; Tue, 24 Aug 2021 14:26:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3EF61036D33; Tue, 24 Aug 2021 14:26:02 +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 9AB0D4A70B; Tue, 24 Aug 2021 14:26:02 +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 17OEQ19Z003533 for ; Tue, 24 Aug 2021 10:26:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6E4026A912; Tue, 24 Aug 2021 14:26:01 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id EABCA6A8FE for ; Tue, 24 Aug 2021 14:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815171; 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=xGQr9cFpwb8xY80pKclzG9c9ORXp0ilOQxPnkiTGl/0=; b=Hzp8RgwnsfTRygG9z/EMOwVaBBQMI0aq2jFcESCuhCxZtV+oduFjUN3lfB19dfDWt/8b7B manU01dmvJGbqAB1y5+xUXZaasu3mt8GR6UIVPk5oo7gHAFpjCmoPK+Ug+iF+L2kbyhkoi 5toNTMZs5BbWB63KnkknVbij03CrZZ8= X-MC-Unique: y3717PwWMXCJuLnrAVnGAQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 09/11] scripts: group-qemu-caps: only pass relevant lines to regroup_caps Date: Tue, 24 Aug 2021 16:25:12 +0200 Message-Id: <97070ce021a7bae1693102958a87e6f0c8b9f4aa.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.84 on 10.5.11.22 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: 1629815172474100001 This makes reconstructing the fixed version of the file a bit more difficult, but lets us get rid of a cryptic bool. Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 63 +++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index dce25099b8..36a7d7602f 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -61,48 +61,41 @@ def load_caps_flags(lines): return capsflags =20 =20 -def regroup_caps(original, start_regex, end_regex, +def regroup_caps(original, trailing_newline, counter_prefix, capsflags): step =3D 5 fixed =3D [] - game_on =3D False counter =3D 0 for line in original: - if game_on: - if re.search(r'''.*/\* [0-9]+ \*/.*''', line): - continue - if re.search(r'''^\s*$''', line): - continue - if counter % step =3D=3D 0: - if counter !=3D 0: - fixed.append("") - fixed.append("%s/* %d */" % (counter_prefix, counter)) - - if not (line.find("/*") !=3D -1 and line.find("*/") =3D=3D -1): - # count two-line comments as one line - counter =3D counter + 1 - - if re.search(start_regex, line): - game_on =3D True - elif game_on and re.search(end_regex, line): - if (counter - 1) % step =3D=3D 0: - fixed =3D fixed[:-1] # /* $counter */ - if counter !=3D 1: - fixed =3D fixed[:-1] # \n - - if trailing_newline: + if re.search(r'''.*/\* [0-9]+ \*/.*''', line): + continue + if re.search(r'''^\s*$''', line): + continue + if counter % step =3D=3D 0: + if counter !=3D 0: fixed.append("") + fixed.append("%s/* %d */" % (counter_prefix, counter)) =20 - game_on =3D False + if not (line.find("/*") !=3D -1 and line.find("*/") =3D=3D -1): + # count two-line comments as one line + counter =3D counter + 1 =20 # ensure that flag names in the .c file have the correct flag in t= he comment - if game_on and capsflags: + if capsflags: flagname =3D re.search(r'''.*".*",''', line) if flagname: line =3D flagname[0] + " /* %s */" % capsflags[counter - 1] =20 fixed.append(line) =20 + if (counter - 1) % step =3D=3D 0: + fixed =3D fixed[:-1] # /* $counter */ + if counter !=3D 1: + fixed =3D fixed[:-1] # \n + + if trailing_newline: + fixed.append("") + return fixed =20 =20 @@ -147,28 +140,28 @@ source_lines =3D load_file(source_path) 'QEMU_CAPS_LAST /* this must') capsflags =3D load_caps_flags(header_lines[start:end]) =20 -header_fixed =3D regroup_caps(header_lines, - r'virQEMUCapsFlags grouping marker', - r'QEMU_CAPS_LAST \/\* this must', +(source_start, source_end) =3D find_markers(source_lines, + 'virQEMUCaps grouping marker', + ' );') + +header_fixed =3D regroup_caps(header_lines[start + 1:end], 1, " ", None) -source_fixed =3D regroup_caps(source_lines, - r'virQEMUCaps grouping marker', - r'\);', +source_fixed =3D regroup_caps(source_lines[source_start + 1:source_end], 0, " ", capsflags) =20 if not check_wrapping(header_path, header_lines, - header_fixed, + header_lines[:start + 1] + header_fixed + header_lin= es[end:], args.check): ret =3D False =20 if not check_wrapping(source_path, source_lines, - source_fixed, + source_lines[:source_start + 1] + source_fixed + sou= rce_lines[source_end:], args.check): ret =3D False =20 --=20 2.31.1 From nobody Sun May 5 13:19:27 2024 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=1629815189; cv=none; d=zohomail.com; s=zohoarc; b=OzoDFFWIVK6LRJIBxuQ1Ya09EkZgRxagNFyJLKyS3XfYlejuIScRV/S7l/2q6XEa15D6lThENU1gFKkcuAqhp/FYuRO2NVwnV531qGR2JaM0D2z78pRjJ3dzga+GoS96TnQWuKEGBTPj2Klvd3W0NxXETgJctzg/tceBMR45pU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815189; 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=Od8sbjOUrc30rhxsOk+Tj/U0+995LA7lYiSPdnepHqc=; b=N2/Z3TCc+FNxJs3Lt1r62nXqgFZ0O/rIDNVg5pxPlGEH3vmX1xvG8+9PaLH17g04vOzaD2h9Va+ErOY0BJXp1jSm/CXotjuudqlaEQQVAQZ/KdzYjQA0GpUw33rd4m+eKqTQiLu7OFyjpJRNE2rZFcFmCoUhJ8N947sW7zNHYTs= 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 1629815189276136.98042911851235; Tue, 24 Aug 2021 07:26:29 -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-292-UXAVkGTjMACuhpd_mxxArA-1; Tue, 24 Aug 2021 10:26:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 985BE18C89D9; Tue, 24 Aug 2021 14:26:20 +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 785A85DF21; Tue, 24 Aug 2021 14:26:20 +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 44EAB181A2AC; Tue, 24 Aug 2021 14:26:20 +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 17OEQJAN003974 for ; Tue, 24 Aug 2021 10:26:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 871B36A8FE; Tue, 24 Aug 2021 14:26:19 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DAF06A8FA for ; Tue, 24 Aug 2021 14:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815188; 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=Od8sbjOUrc30rhxsOk+Tj/U0+995LA7lYiSPdnepHqc=; b=RF+IfWJa6awqWv2jwnGMvvfEHtPc3Vz1Ujn7nATw7Hm7LUfKZ8PyA/rVhzmt/IgnI1urqH 2zXg1T/f+HfbncwnGt/BTf4VyU6URy9zZrItmVDhs23QDoZ1qDwVfG3ZxxyIMJAeTwtcuQ RZ4p8SjENWIL7niB4vRXN5gDQnw95BM= X-MC-Unique: UXAVkGTjMACuhpd_mxxArA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 10/11] scripts: group-qemu-caps: reorder arguments Date: Tue, 24 Aug 2021 16:25:13 +0200 Message-Id: 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.14 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: 1629815191227100001 Make some arguments optional. Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index 36a7d7602f..bcda29a6ca 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -61,8 +61,8 @@ def load_caps_flags(lines): return capsflags =20 =20 -def regroup_caps(original, - trailing_newline, counter_prefix, capsflags): +def regroup_caps(original, counter_prefix, capsflags=3DNone, + trailing_newline=3DFalse): step =3D 5 fixed =3D [] counter =3D 0 @@ -145,13 +145,11 @@ capsflags =3D load_caps_flags(header_lines[start:end]) ' );') =20 header_fixed =3D regroup_caps(header_lines[start + 1:end], - 1, " ", - None) + trailing_newline=3DTrue) source_fixed =3D regroup_caps(source_lines[source_start + 1:source_end], - 0, " ", - capsflags) + capsflags=3Dcapsflags) =20 if not check_wrapping(header_path, header_lines, --=20 2.31.1 From nobody Sun May 5 13:19:27 2024 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=1629815194; cv=none; d=zohomail.com; s=zohoarc; b=O1veSaennuB5iPXDI58mb/Z6YTRATaCD2itfoOzPFEm6GD+hPSiIrgjToxOCnBV4Qzbh1ZkHQLC3TfSJMQdaU0tz+ou0vqB7bEt63AzGUQNIjEkjdTiISdYSsOrJvkR/j9Zfe6/WFCD13jWub3+TRh6CPrNK38J+LKnxYBza6Ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629815194; 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=mloHyEWKO0OgGkq6SDrtAZpMw8/7VsL5Jebp9eaV/OE=; b=n6LgaGlt6tP+U+Z61bgcjOkFQ/ws3vevlYoK48selLPgBW3l0HYe5YUBS2SvOg4NrO1Mr8/w1QSI/HnvggnOx88ESZd+SdurD/F0r0qw1dbD9fEkIc4K8mpg31jDAgT7r/oGcGaW1VHC95IAgmrw9YzLT7XoPFxCVvSYW+dMenM= 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 1629815194770978.6490507041349; Tue, 24 Aug 2021 07:26:34 -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-28-Y9Qy6LDgMqiqjpcb36JAfg-1; Tue, 24 Aug 2021 10:26:31 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5ABC9801A92; Tue, 24 Aug 2021 14:26:26 +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 33A0D10013D6; Tue, 24 Aug 2021 14:26:26 +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 0097A181A2AE; Tue, 24 Aug 2021 14:26:25 +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 17OEQOhM004096 for ; Tue, 24 Aug 2021 10:26:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id DF84018432; Tue, 24 Aug 2021 14:26:24 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 680135D6CF for ; Tue, 24 Aug 2021 14:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629815193; 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=mloHyEWKO0OgGkq6SDrtAZpMw8/7VsL5Jebp9eaV/OE=; b=b3SEbavheyR0ybsRlNZWfBci3O6Vu0OwKX1cIR0D+yoc2f14TNmQEOI2TZczHmAmKALErQ Q5PYOxNVMQ7i3ypFY+p7lGx31OX6yXvKAXqdh62S/p6zpkHBWUY3d9AZzmF8iOstTCnb5w kiDmgGJ0vvgmCUKFNIhaZQkbnA0Wceo= X-MC-Unique: Y9Qy6LDgMqiqjpcb36JAfg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 11/11] scripts: group-qemu-caps: remove Errs variable Date: Tue, 24 Aug 2021 16:25:14 +0200 Message-Id: <4df01ea7f65c16b603a2bb97fc6fd4cf1cdda559.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.84 on 10.5.11.22 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: 1629815195841100001 Use ret and exit with it directly. Signed-off-by: J=C3=A1n Tomko --- scripts/group-qemu-caps.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/group-qemu-caps.py b/scripts/group-qemu-caps.py index bcda29a6ca..356d9e8d06 100755 --- a/scripts/group-qemu-caps.py +++ b/scripts/group-qemu-caps.py @@ -128,8 +128,6 @@ parser.add_argument('--prefix', default=3D'', help=3D'source code tree prefix') args =3D parser.parse_args() =20 -errs =3D False - header_path =3D args.prefix + 'src/qemu/qemu_capabilities.h' source_path =3D args.prefix + 'src/qemu/qemu_capabilities.c' =20 @@ -151,18 +149,18 @@ source_fixed =3D regroup_caps(source_lines[source_sta= rt + 1:source_end], " ", capsflags=3Dcapsflags) =20 +ret =3D 0 + if not check_wrapping(header_path, header_lines, header_lines[:start + 1] + header_fixed + header_lin= es[end:], args.check): - ret =3D False + ret =3D 1 =20 if not check_wrapping(source_path, source_lines, source_lines[:source_start + 1] + source_fixed + sou= rce_lines[source_end:], args.check): - ret =3D False + ret =3D 1 =20 -if errs: - sys.exit(1) -sys.exit(0) +sys.exit(ret) --=20 2.31.1