From nobody Thu Oct 31 00:25:22 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